Properly handle groupIds in incoming block sync

This commit is contained in:
Scott Nonnenberg 2022-01-19 16:39:27 -08:00 committed by GitHub
parent a802188f33
commit f1586578ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 15 deletions

View file

@ -879,7 +879,7 @@ export class ConversationModel extends window.Backbone
block({ viaStorageServiceSync = false } = {}): void {
let blocked = false;
const isBlocked = this.isBlocked();
const wasBlocked = this.isBlocked();
const uuid = this.get('uuid');
if (uuid) {
@ -899,14 +899,19 @@ export class ConversationModel extends window.Backbone
blocked = true;
}
if (!viaStorageServiceSync && !isBlocked && blocked) {
this.captureChange('block');
if (blocked && !wasBlocked) {
// We need to force a props refresh - blocked state is not in backbone attributes
this.trigger('change', this, { force: true });
if (!viaStorageServiceSync) {
this.captureChange('block');
}
}
}
unblock({ viaStorageServiceSync = false } = {}): boolean {
let unblocked = false;
const isBlocked = this.isBlocked();
const wasBlocked = this.isBlocked();
const uuid = this.get('uuid');
if (uuid) {
@ -926,8 +931,13 @@ export class ConversationModel extends window.Backbone
unblocked = true;
}
if (!viaStorageServiceSync && isBlocked && unblocked) {
this.captureChange('unblock');
if (unblocked && wasBlocked) {
// We need to force a props refresh - blocked state is not in backbone attributes
this.trigger('change', this, { force: true });
if (!viaStorageServiceSync) {
this.captureChange('unblock');
}
}
return unblocked;