Ensure chat list matches primary after backup import for certain directionless-message-only chats
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
parent
9677601155
commit
32cea7c170
1 changed files with 62 additions and 1 deletions
|
@ -1331,9 +1331,13 @@ export class BackupImportStream extends Writable {
|
|||
unread,
|
||||
} = this.fromDirectionDetails(item, timestamp);
|
||||
|
||||
if (newActiveAt != null) {
|
||||
if (
|
||||
newActiveAt != null &&
|
||||
this.shouldChatItemAffectChatListPresence(item)
|
||||
) {
|
||||
chatConvo.active_at = newActiveAt;
|
||||
}
|
||||
|
||||
if (unread != null) {
|
||||
chatConvo.unreadCount = (chatConvo.unreadCount ?? 0) + 1;
|
||||
}
|
||||
|
@ -1619,6 +1623,63 @@ export class BackupImportStream extends Writable {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Some update messages should not affect the chat's position in the left pane chat
|
||||
* list. For example, conversations with only an identity update (SN change) message
|
||||
* should not show in the left pane.
|
||||
*/
|
||||
private shouldChatItemAffectChatListPresence(
|
||||
item: Backups.IChatItem
|
||||
): boolean {
|
||||
if (!item.updateMessage) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.updateMessage.simpleUpdate) {
|
||||
switch (item.updateMessage.simpleUpdate.type) {
|
||||
case Backups.SimpleChatUpdate.Type.IDENTITY_UPDATE:
|
||||
case Backups.SimpleChatUpdate.Type.CHANGE_NUMBER:
|
||||
case Backups.SimpleChatUpdate.Type.MESSAGE_REQUEST_ACCEPTED:
|
||||
case Backups.SimpleChatUpdate.Type.REPORTED_SPAM:
|
||||
case undefined:
|
||||
case null:
|
||||
return false;
|
||||
// Listing all of these out (rather than a default case) so that TS will force us
|
||||
// to update this list when a new type is introduced
|
||||
case Backups.SimpleChatUpdate.Type.BAD_DECRYPT:
|
||||
case Backups.SimpleChatUpdate.Type.BLOCKED:
|
||||
case Backups.SimpleChatUpdate.Type.CHAT_SESSION_REFRESH:
|
||||
case Backups.SimpleChatUpdate.Type.END_SESSION:
|
||||
case Backups.SimpleChatUpdate.Type.IDENTITY_DEFAULT:
|
||||
case Backups.SimpleChatUpdate.Type.IDENTITY_VERIFIED:
|
||||
case Backups.SimpleChatUpdate.Type.JOINED_SIGNAL:
|
||||
case Backups.SimpleChatUpdate.Type.PAYMENTS_ACTIVATED:
|
||||
case Backups.SimpleChatUpdate.Type.PAYMENT_ACTIVATION_REQUEST:
|
||||
case Backups.SimpleChatUpdate.Type.RELEASE_CHANNEL_DONATION_REQUEST:
|
||||
case Backups.SimpleChatUpdate.Type.UNBLOCKED:
|
||||
case Backups.SimpleChatUpdate.Type.UNKNOWN:
|
||||
case Backups.SimpleChatUpdate.Type.UNSUPPORTED_PROTOCOL_MESSAGE:
|
||||
return true;
|
||||
default:
|
||||
throw missingCaseError(item.updateMessage.simpleUpdate.type);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
item.updateMessage.groupChange?.updates?.every(update =>
|
||||
Boolean(update.groupMemberLeftUpdate)
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.updateMessage.profileChange) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async fromStandardMessage(
|
||||
data: Backups.IStandardMessage
|
||||
): Promise<Partial<MessageAttributesType>> {
|
||||
|
|
Loading…
Reference in a new issue