Merge pull request #524 from vector-im/bwindels/fix-492

clear relations for room when forgetting room
This commit is contained in:
Bruno Windels 2021-09-30 09:51:59 +02:00 committed by GitHub
commit dcb08f5266
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

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

View file

@ -57,6 +57,16 @@ export class TimelineRelationStore {
this._store.delete(range); 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[]> { async getForTargetAndType(roomId: string, targetId: string, relType: string): Promise<RelationEntry[]> {
// exclude both keys as they are theoretical min and max, // 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 // but we should't have a match for just the room id, or room id with max