Better logging for pin/unpin

This commit is contained in:
Josh Perez 2020-10-14 20:36:31 -04:00 committed by Josh Perez
parent 8446b2dc61
commit fac1f26ad2
2 changed files with 28 additions and 14 deletions

View File

@ -660,7 +660,7 @@ export class ConversationModel extends window.Backbone.Model<
}
if (!viaStorageServiceSync && !isBlocked && blocked) {
this.captureChange();
this.captureChange('block');
}
}
@ -687,7 +687,7 @@ export class ConversationModel extends window.Backbone.Model<
}
if (!viaStorageServiceSync && isBlocked && unblocked) {
this.captureChange();
this.captureChange('unblock');
}
return unblocked;
@ -701,7 +701,7 @@ export class ConversationModel extends window.Backbone.Model<
const after = this.get('profileSharing');
if (!viaStorageServiceSync && Boolean(before) !== Boolean(after)) {
this.captureChange();
this.captureChange('profileSharing');
}
}
@ -713,7 +713,7 @@ export class ConversationModel extends window.Backbone.Model<
const after = this.get('profileSharing');
if (!viaStorageServiceSync && Boolean(before) !== Boolean(after)) {
this.captureChange();
this.captureChange('profileSharing');
}
}
@ -1484,7 +1484,7 @@ export class ConversationModel extends window.Backbone.Model<
!keyChange &&
beginningVerified !== verified
) {
this.captureChange();
this.captureChange('verified');
}
// Three situations result in a verification notice in the conversation:
@ -2923,7 +2923,7 @@ export class ConversationModel extends window.Backbone.Model<
if (after) {
this.unpin();
}
this.captureChange();
this.captureChange('isArchived');
}
}
@ -3653,7 +3653,7 @@ export class ConversationModel extends window.Backbone.Model<
!viaStorageServiceSync &&
profileKey !== this.get('storageProfileKey')
) {
this.captureChange();
this.captureChange('profileKey');
}
await Promise.all([
@ -3907,7 +3907,7 @@ export class ConversationModel extends window.Backbone.Model<
// [X] blocked
// [X] whitelisted
// [X] archived
captureChange(): void {
captureChange(property: string): void {
if (!window.Signal.RemoteConfig.isEnabled('desktop.storageWrite')) {
window.log.info(
'conversation.captureChange: Returning early; desktop.storageWrite is falsey'
@ -3917,7 +3917,9 @@ export class ConversationModel extends window.Backbone.Model<
}
window.log.info(
`storageService[captureChange] marking ${this.debugID()} as needing sync`
'storageService[captureChange]',
property,
this.idForLogging()
);
this.set({ needsStorageServiceSync: true });
@ -4062,6 +4064,7 @@ export class ConversationModel extends window.Backbone.Model<
}
pin(): void {
window.log.info('pinning', this.idForLogging());
const pinnedConversationIds = new Set(
window.storage.get<Array<string>>('pinnedConversationIds', [])
);
@ -4080,6 +4083,8 @@ export class ConversationModel extends window.Backbone.Model<
}
unpin(): void {
window.log.info('un-pinning', this.idForLogging());
const pinnedConversationIds = new Set(
window.storage.get<Array<string>>('pinnedConversationIds', [])
);
@ -4100,7 +4105,7 @@ export class ConversationModel extends window.Backbone.Model<
const me = window.ConversationController.get(myId);
if (me) {
me.captureChange();
me.captureChange('pin');
}
}
}

View File

@ -584,6 +584,11 @@ export async function mergeAccountRecord(
conversation => Boolean(conversation.get('isPinned'))
);
window.log.info(
'storageService.mergeAccountRecord: Local pinned',
locallyPinnedConversations.length
);
const remotelyPinnedConversationPromises = remotelyPinnedConversationClasses.map(
async pinnedConversation => {
let conversationId;
@ -621,13 +626,15 @@ export async function mergeAccountRecord(
break;
}
default: {
window.log.error('mergeAccountRecord: Invalid identifier received');
window.log.error(
'storageService.mergeAccountRecord: Invalid identifier received'
);
}
}
if (!conversationId) {
window.log.error(
'mergeAccountRecord: missing conversation id. looking based on',
'storageService.mergeAccountRecord: missing conversation id. looking based on',
pinnedConversation.identifier
);
return undefined;
@ -660,11 +667,13 @@ export async function mergeAccountRecord(
);
window.log.info(
`mergeAccountRecord: unpinning ${conversationsToUnpin.length} conversations`
'storageService.mergeAccountRecord: unpinning',
conversationsToUnpin.length
);
window.log.info(
`mergeAccountRecord: pinning ${conversationsToUnpin.length} conversations`
'storageService.mergeAccountRecord: pinning',
remotelyPinnedConversations.length
);
conversationsToUnpin.forEach(conversation => {