Make sure isPinned is in sync with storage service
This commit is contained in:
parent
40983ca73e
commit
891e72a260
3 changed files with 30 additions and 8 deletions
|
@ -832,6 +832,25 @@ export class ConversationController {
|
||||||
this.get(conversationId)?.onOpenComplete(loadStart);
|
this.get(conversationId)?.onOpenComplete(loadStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repairPinnedConversations(): void {
|
||||||
|
const pinnedIds = window.storage.get('pinnedConversationIds', []);
|
||||||
|
|
||||||
|
for (const id of pinnedIds) {
|
||||||
|
const convo = this.get(id);
|
||||||
|
|
||||||
|
if (!convo || convo.get('isPinned')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn(
|
||||||
|
`ConversationController: Repairing ${convo.idForLogging()}'s isPinned`
|
||||||
|
);
|
||||||
|
convo.set('isPinned', true);
|
||||||
|
|
||||||
|
window.Signal.Data.updateConversation(convo.attributes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async doLoad(): Promise<void> {
|
private async doLoad(): Promise<void> {
|
||||||
log.info('ConversationController: starting initial fetch');
|
log.info('ConversationController: starting initial fetch');
|
||||||
|
|
||||||
|
|
|
@ -459,6 +459,7 @@ export async function startApp(): Promise<void> {
|
||||||
log.info('environment:', window.getEnvironment());
|
log.info('environment:', window.getEnvironment());
|
||||||
|
|
||||||
let newVersion = false;
|
let newVersion = false;
|
||||||
|
let lastVersion: string | undefined;
|
||||||
|
|
||||||
window.document.title = window.getTitle();
|
window.document.title = window.getTitle();
|
||||||
|
|
||||||
|
@ -640,7 +641,7 @@ export async function startApp(): Promise<void> {
|
||||||
);
|
);
|
||||||
|
|
||||||
const currentVersion = window.getVersion();
|
const currentVersion = window.getVersion();
|
||||||
const lastVersion = window.storage.get('version');
|
lastVersion = window.storage.get('version');
|
||||||
newVersion = !lastVersion || currentVersion !== lastVersion;
|
newVersion = !lastVersion || currentVersion !== lastVersion;
|
||||||
await window.storage.put('version', currentVersion);
|
await window.storage.put('version', currentVersion);
|
||||||
|
|
||||||
|
@ -1679,6 +1680,12 @@ export async function startApp(): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newVersion && lastVersion) {
|
||||||
|
if (window.isBeforeVersion(lastVersion, 'v5.31.0')) {
|
||||||
|
window.ConversationController.repairPinnedConversations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
window.dispatchEvent(new Event('storage_ready'));
|
window.dispatchEvent(new Event('storage_ready'));
|
||||||
|
|
||||||
badgeImageFileDownloader.checkForFilesToDownload();
|
badgeImageFileDownloader.checkForFilesToDownload();
|
||||||
|
|
|
@ -4159,9 +4159,7 @@ export class ConversationModel extends window.Backbone
|
||||||
|
|
||||||
if (Boolean(before) !== Boolean(after)) {
|
if (Boolean(before) !== Boolean(after)) {
|
||||||
if (after) {
|
if (after) {
|
||||||
// we're capturing a storage sync below so
|
this.unpin();
|
||||||
// we don't need to capture it twice
|
|
||||||
this.unpin({ stopStorageSync: true });
|
|
||||||
}
|
}
|
||||||
this.captureChange('isArchived');
|
this.captureChange('isArchived');
|
||||||
}
|
}
|
||||||
|
@ -5274,7 +5272,7 @@ export class ConversationModel extends window.Backbone
|
||||||
window.Signal.Data.updateConversation(this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
unpin({ stopStorageSync = false } = {}): void {
|
unpin(): void {
|
||||||
if (!this.get('isPinned')) {
|
if (!this.get('isPinned')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5287,9 +5285,7 @@ export class ConversationModel extends window.Backbone
|
||||||
|
|
||||||
pinnedConversationIds.delete(this.id);
|
pinnedConversationIds.delete(this.id);
|
||||||
|
|
||||||
if (!stopStorageSync) {
|
this.writePinnedConversations([...pinnedConversationIds]);
|
||||||
this.writePinnedConversations([...pinnedConversationIds]);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.set('isPinned', false);
|
this.set('isPinned', false);
|
||||||
window.Signal.Data.updateConversation(this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue