1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Fix issue where no unsubs are sent when switching rooms

This commit is contained in:
Till Faelligen
2022-12-16 11:49:31 +01:00
parent c973b26fa2
commit a04800f030

View File

@@ -397,6 +397,10 @@ export class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSync
* @param sub - The subscription information.
*/
public addCustomSubscription(name: string, sub: MSC3575RoomSubscription): void {
if (this.customSubscriptions.get(name) !== undefined) {
logger.warn(`addCustomSubscription: ${name} already exists as a custom subscription, ignoring.`);
return;
}
this.customSubscriptions.set(name, sub);
}
@@ -408,6 +412,11 @@ export class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSync
* will be used.
*/
public useCustomSubscription(roomId: string, name: string): void {
// We already know about this custom subscription, as it is immutable,
// we don't need to unconfirm the subscription.
if (this.roomIdToCustomSubscription.get(roomId) === name) {
return;
}
this.roomIdToCustomSubscription.set(roomId, name);
// unconfirm this subscription so a resend() will send it up afresh.
this.confirmedRoomSubscriptions.delete(roomId);