mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
- Enable sliding sync in config.json with matrix.org proxy - Update font from InterVariable to SF Pro Display - Add sliding sync state management with Jotai atoms - Create bridge between sliding sync and existing room list atoms - Add sliding sync settings UI in General settings - Implement purple theme with gradient enhancements - Add synchronization status display for sliding sync - Update client initialization to support sliding sync 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { createContext, useContext } from 'react';
|
|
|
|
export type HashRouterConfig = {
|
|
enabled?: boolean;
|
|
basename?: string;
|
|
};
|
|
|
|
export type SlidingSyncListConfig = {
|
|
ranges: number[][];
|
|
sort?: string[];
|
|
timeline_limit?: number;
|
|
required_state?: string[][];
|
|
filters?: Record<string, any>;
|
|
};
|
|
|
|
export type SlidingSyncConfig = {
|
|
enabled?: boolean;
|
|
proxyUrl?: string | null;
|
|
defaultLists?: Record<string, SlidingSyncListConfig>;
|
|
};
|
|
|
|
export type ClientConfig = {
|
|
defaultHomeserver?: number;
|
|
homeserverList?: string[];
|
|
allowCustomHomeservers?: boolean;
|
|
|
|
featuredCommunities?: {
|
|
openAsDefault?: boolean;
|
|
spaces?: string[];
|
|
rooms?: string[];
|
|
servers?: string[];
|
|
};
|
|
|
|
hashRouter?: HashRouterConfig;
|
|
slidingSync?: SlidingSyncConfig;
|
|
};
|
|
|
|
const ClientConfigContext = createContext<ClientConfig | null>(null);
|
|
|
|
export const ClientConfigProvider = ClientConfigContext.Provider;
|
|
|
|
export function useClientConfig(): ClientConfig {
|
|
const config = useContext(ClientConfigContext);
|
|
if (!config) throw new Error('Client config are not provided!');
|
|
return config;
|
|
}
|
|
|
|
export const clientDefaultServer = (clientConfig: ClientConfig): string =>
|
|
clientConfig.homeserverList?.[clientConfig.defaultHomeserver ?? 0] ?? 'matrix.org';
|
|
|
|
export const clientAllowedServer = (clientConfig: ClientConfig, server: string): boolean => {
|
|
const { homeserverList, allowCustomHomeservers } = clientConfig;
|
|
|
|
if (allowCustomHomeservers) return true;
|
|
|
|
return homeserverList?.includes(server) === true;
|
|
};
|