feat(web): add spaces, grouped channels and file chat
This commit is contained in:
1 parent
c7d8ef15bc
commit
f6cfb12716
111 files changed
+4371
-506
No files matched your search
@@ -4,17 +4,18 @@ import type { ChannelInfo, CreateOptions } from '@/core-bridge/types';
|
||||
import type { ParsedChannelLink } from '@/lib/channelLink';
|
||||
|
||||
interface ChannelsState {
|
||||
/** 我的频道(原型:只在内存里,刷新即清空;真实实现存 IndexedDB,architecture §6) */
|
||||
/** 我的空间(原型:只在内存里,刷新即清空;真实实现存 IndexedDB,architecture §6) */
|
||||
list: ChannelInfo[];
|
||||
hydrated: boolean;
|
||||
/** 从链接进来、还没确认加入的频道;含密钥,只放内存 */
|
||||
/** 从链接进来、还没确认加入的空间;含密钥,只放内存 */
|
||||
pendingLink: ParsedChannelLink | null;
|
||||
/** 刚创建的频道:进入时直接展示分享面板与二维码 */
|
||||
/** 刚创建的空间:进入时直接展示分享面板与二维码 */
|
||||
justCreatedId: string | null;
|
||||
|
||||
create: (opts: CreateOptions, captchaToken?: string) => Promise<ChannelInfo>;
|
||||
join: (link: ParsedChannelLink) => Promise<ChannelInfo>;
|
||||
join: (link: ParsedChannelLink, password?: string) => Promise<ChannelInfo>;
|
||||
hydrate: () => Promise<void>;
|
||||
refresh: () => Promise<void>;
|
||||
forget: (id: string) => Promise<void>;
|
||||
loadDemo: () => void;
|
||||
setPendingLink: (link: ParsedChannelLink | null) => void;
|
||||
@@ -35,8 +36,8 @@ export const useChannels = create<ChannelsState>()((set) => ({
|
||||
set((s) => ({ list: upsert(s.list, c), justCreatedId: c.id }));
|
||||
return c;
|
||||
},
|
||||
join: async (link) => {
|
||||
const c = await api.joinChannel(link);
|
||||
join: async (link, password) => {
|
||||
const c = await api.joinChannel(link, password);
|
||||
set((s) => ({ list: upsert(s.list, c), pendingLink: null }));
|
||||
return c;
|
||||
},
|
||||
@@ -44,6 +45,7 @@ export const useChannels = create<ChannelsState>()((set) => ({
|
||||
hydration ??= api.listSaved().then((list) => set({ list, hydrated: true }), () => set({ hydrated: true }));
|
||||
return hydration;
|
||||
},
|
||||
refresh: async () => set({ list: await api.listSaved(), hydrated: true }),
|
||||
forget: async (id) => {
|
||||
await api.forget(id);
|
||||
set((s) => ({ list: s.list.filter((c) => c.id !== id) }));
|
||||
|
||||
Reference in new issue
Block a user