perf(web): shorten the cold start when opening a saved space
Activate the account with parallel requests, run the full vault sync in the background, skip the duplicate space list request, and send the rejoin together with the first screen of data. [CI]
This commit is contained in:
1 parent
f2e118c966
commit
b1ac11e1d7
3 files changed
+19
-11
No files matched your search
@@ -24,7 +24,7 @@ interface ChannelsState {
|
||||
const upsert = (list: ChannelInfo[], c: ChannelInfo) => [c, ...list.filter((x) => x.id !== c.id)];
|
||||
let hydration: Promise<void> | undefined;
|
||||
|
||||
export const useChannels = create<ChannelsState>()((set) => ({
|
||||
export const useChannels = create<ChannelsState>()((set, get) => ({
|
||||
list: [],
|
||||
hydrated: false,
|
||||
pendingLink: null,
|
||||
@@ -41,6 +41,8 @@ export const useChannels = create<ChannelsState>()((set) => ({
|
||||
return c;
|
||||
},
|
||||
hydrate: () => {
|
||||
// 账号刷新已经列过一次,别再请求一遍
|
||||
if (get().hydrated) return Promise.resolve();
|
||||
hydration ??= api.listSaved().then((list) => set({ list, hydrated: true }), () => set({ hydrated: true }));
|
||||
return hydration;
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user