perf(web): shorten the first open of a space for new members
Accepting an invitation no longer waits for the vault sync, the redundant join right after joining is skipped, and the crypto state, first log page and channel metadata are requested in parallel.
This commit is contained in:
1 parent
d4a72bf177
commit
06fe077ef1
6 files changed
+26
-9
No files matched your search
@@ -129,15 +129,19 @@ export async function channelMetadata(resource: SavedResource, session: ChannelS
|
||||
}
|
||||
|
||||
export async function syncChannel(resource: SavedResource, session: ChannelSession, signal: AbortSignal): Promise<number> {
|
||||
if (resource.mode === 'enc') await readDataKeys(resource, session);
|
||||
// reset 必须同步发出:connectChannel 随后并行拉取频道信息,它们的结果要落在 reset 之后
|
||||
publishWorkspace(resource.id, { t: 'reset' });
|
||||
clearFileCatalog(resource.id);
|
||||
readers.set(resource.id, session.createItemReader());
|
||||
// 密钥与第一页日志互不依赖,同时发出,首次打开少等一个往返
|
||||
const keys = resource.mode === 'enc' ? readDataKeys(resource, session) : undefined;
|
||||
keys?.catch(() => undefined);
|
||||
let from = 0;
|
||||
for (;;) {
|
||||
for (let first = true; ; first = false) {
|
||||
const response = await apiFetch(`/channels/${resource.id}/log?from=${from}&limit=200`, {
|
||||
headers: session.authHeaders('read'), signal,
|
||||
});
|
||||
if (first) await keys;
|
||||
const records = parseLogRecords(new Uint8Array(await response.arrayBuffer()));
|
||||
for (const record of records) {
|
||||
await applyChannelRecord(resource, session, record);
|
||||
|
||||
Reference in new issue
Block a user