clear relations for room when forgetting room

This commit is contained in:
Bruno Windels 2021-09-30 09:49:45 +02:00
parent 4cebe26186
commit d10d27c1d6
2 changed files with 12 additions and 0 deletions

View File

@ -138,6 +138,7 @@ export class ArchivedRoom extends BaseRoom {
storeNames.roomMembers,
storeNames.timelineEvents,
storeNames.timelineFragments,
storeNames.timelineRelations,
storeNames.pendingEvents,
storeNames.inboundGroupSessions,
storeNames.groupSessionDecryptions,
@ -149,6 +150,7 @@ export class ArchivedRoom extends BaseRoom {
txn.roomMembers.removeAllForRoom(this.id);
txn.timelineEvents.removeAllForRoom(this.id);
txn.timelineFragments.removeAllForRoom(this.id);
txn.timelineRelations.removeAllForRoom(this.id);
txn.pendingEvents.removeAllForRoom(this.id);
txn.inboundGroupSessions.removeAllForRoom(this.id);
txn.groupSessionDecryptions.removeAllForRoom(this.id);

View File

@ -57,6 +57,16 @@ export class TimelineRelationStore {
this._store.delete(range);
}
removeAllForRoom(roomId: string) {
const range = this._store.IDBKeyRange.bound(
encodeKey(roomId, MIN_UNICODE, MIN_UNICODE, MIN_UNICODE),
encodeKey(roomId, MAX_UNICODE, MAX_UNICODE, MAX_UNICODE),
true,
true
);
this._store.delete(range);
}
async getForTargetAndType(roomId: string, targetId: string, relType: string): Promise<RelationEntry[]> {
// exclude both keys as they are theoretical min and max,
// but we should't have a match for just the room id, or room id with max