mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-03 23:32:22 -08:00
fix unreads
seems to require a timeline item sadly
This commit is contained in:
1 parent
071b29bff7
commit
b68bc73e80
4 files changed
+105
-30
No files matched your search
@@ -111,6 +111,7 @@ describe('SlidingSyncManager initial request', () => {
|
||||
};
|
||||
|
||||
expect(joined?.ranges).toEqual([[0, 29]]);
|
||||
expect(joined?.timeline_limit).toBe(1);
|
||||
expect(joined?.required_state).toHaveLength(8);
|
||||
expect(joined?.required_state).toContainEqual([EventType.RoomJoinRules, '']);
|
||||
expect(joined?.required_state).not.toContainEqual(['m.space.child', '*']);
|
||||
@@ -118,6 +119,24 @@ describe('SlidingSyncManager initial request', () => {
|
||||
expect(mocks.slidingSyncConstructorArgs?.[4]).toBe(45000);
|
||||
});
|
||||
|
||||
it('settles response processing after post-response work can finish', async () => {
|
||||
const manager = makeManager(makeMockMx());
|
||||
const settled = vi.fn<() => void>();
|
||||
manager.subscribeToResponseSettled(settled);
|
||||
manager.attach();
|
||||
|
||||
fireLifecycle(SlidingSyncState.RequestFinished, {});
|
||||
expect(manager.isResponseProcessing()).toBe(true);
|
||||
|
||||
fireLifecycle(SlidingSyncState.Complete, {});
|
||||
expect(manager.isResponseProcessing()).toBe(true);
|
||||
expect(settled).not.toHaveBeenCalled();
|
||||
|
||||
await Promise.resolve();
|
||||
expect(manager.isResponseProcessing()).toBe(false);
|
||||
expect(settled).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('includes the selected room subscription before the first request', () => {
|
||||
const manager = new SlidingSyncManager(makeMockMx(), 'https://sliding.example.com', {
|
||||
initialRoomIds: ['!selected:example.com'],
|
||||
|
||||
@@ -33,7 +33,7 @@ export const LIST_INVITES = 'invites';
|
||||
export const LIST_SEARCH = 'search';
|
||||
export const LIST_ROOM_SEARCH = 'room_search';
|
||||
export const LIST_SPACE = 'space';
|
||||
const LIST_TIMELINE_LIMIT = 0;
|
||||
const LIST_TIMELINE_LIMIT = 1;
|
||||
const LIST_PAGE_SIZE = 30;
|
||||
const DEFAULT_POLL_TIMEOUT_MS = 45000;
|
||||
|
||||
@@ -223,6 +223,10 @@ export class SlidingSyncManager {
|
||||
|
||||
private responseProcessingStartedAt: number | undefined;
|
||||
|
||||
private responseProcessing = false;
|
||||
|
||||
private readonly responseSettledListeners = new Set<() => void>();
|
||||
|
||||
private previousListCounts: Map<string, number> = new Map();
|
||||
|
||||
private readonly requestedListRangeEnds = new Map<string, number>();
|
||||
@@ -310,7 +314,10 @@ export class SlidingSyncManager {
|
||||
}
|
||||
|
||||
if (state === SlidingSyncState.RequestFinished) {
|
||||
if (!err && resp) this.responseProcessingStartedAt = performance.now();
|
||||
if (!err && resp) {
|
||||
this.responseProcessing = true;
|
||||
this.responseProcessingStartedAt = performance.now();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -402,6 +409,12 @@ export class SlidingSyncManager {
|
||||
totalRoomCount,
|
||||
});
|
||||
}
|
||||
|
||||
globalThis.queueMicrotask(() => {
|
||||
if (this.disposed) return;
|
||||
this.responseProcessing = false;
|
||||
this.responseSettledListeners.forEach((listener) => listener());
|
||||
});
|
||||
};
|
||||
|
||||
this.onMembershipLeave = (_event, member) => {
|
||||
@@ -455,6 +468,8 @@ export class SlidingSyncManager {
|
||||
});
|
||||
|
||||
this.pendingRoomDataListeners.clear();
|
||||
this.responseProcessing = false;
|
||||
this.responseSettledListeners.clear();
|
||||
this.roomDataAwaitingSyncCompletion.clear();
|
||||
this.roomSubscriptionStatusListeners.forEach((listeners) =>
|
||||
listeners.forEach((listener) => listener(false))
|
||||
@@ -721,6 +736,15 @@ export class SlidingSyncManager {
|
||||
return this.activeRoomSubscriptions.has(roomId);
|
||||
}
|
||||
|
||||
public isResponseProcessing(): boolean {
|
||||
return this.responseProcessing;
|
||||
}
|
||||
|
||||
public subscribeToResponseSettled(listener: () => void): () => void {
|
||||
this.responseSettledListeners.add(listener);
|
||||
return () => this.responseSettledListeners.delete(listener);
|
||||
}
|
||||
|
||||
public reconcileRoomMembership(
|
||||
roomId: string,
|
||||
membership: KnownMembership.Join | KnownMembership.Leave
|
||||
|
||||
Reference in new issue
Block a user