After import, don't show chats in left pane unless they have messages
This commit is contained in:
parent
97d31cd1a5
commit
ec26b82ba7
4 changed files with 34 additions and 20 deletions
7
ts/model-types.d.ts
vendored
7
ts/model-types.d.ts
vendored
|
@ -504,6 +504,13 @@ export type ConversationAttributesType = {
|
||||||
|
|
||||||
// Legacy field, mapped to above in getConversation()
|
// Legacy field, mapped to above in getConversation()
|
||||||
unblurredAvatarPath?: string;
|
unblurredAvatarPath?: string;
|
||||||
|
|
||||||
|
// Only used during backup integration tests. After import, our data model merges
|
||||||
|
// Contact and Chat frames from a backup, and we will then by default export both, even
|
||||||
|
// if the Chat frame was not imported. That's fine in normal usage, but breaks
|
||||||
|
// integration tests that aren't expecting to see a Chat frame on export that was not
|
||||||
|
// there on import.
|
||||||
|
test_chatFrameImportedFromBackup?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ConversationRenderInfoType = Pick<
|
export type ConversationRenderInfoType = Pick<
|
||||||
|
|
|
@ -140,6 +140,7 @@ import { SeenStatus } from '../../MessageSeenStatus';
|
||||||
import { migrateAllMessages } from '../../messages/migrateMessageData';
|
import { migrateAllMessages } from '../../messages/migrateMessageData';
|
||||||
import { trimBody } from '../../util/longAttachment';
|
import { trimBody } from '../../util/longAttachment';
|
||||||
import { generateBackupsSubscriberData } from '../../util/backupSubscriptionData';
|
import { generateBackupsSubscriberData } from '../../util/backupSubscriptionData';
|
||||||
|
import { getEnvironment, isTestEnvironment } from '../../environment';
|
||||||
|
|
||||||
const MAX_CONCURRENCY = 10;
|
const MAX_CONCURRENCY = 10;
|
||||||
|
|
||||||
|
@ -448,9 +449,18 @@ export class BackupExportStream extends Readable {
|
||||||
pinnedOrder = Math.max(1, index + 1);
|
pinnedOrder = Math.max(1, index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip conversations that have no presence in left pane (no chats)
|
if (isTestEnvironment(getEnvironment())) {
|
||||||
if (!attributes.isPinned && !attributes.active_at) {
|
// In backup integration tests, we may import a Contact/Group without a Chat,
|
||||||
continue;
|
// so we don't wan't to export the (empty) Chat to satisfy the tests.
|
||||||
|
if (
|
||||||
|
!attributes.test_chatFrameImportedFromBackup &&
|
||||||
|
!attributes.isPinned &&
|
||||||
|
!attributes.active_at &&
|
||||||
|
!attributes.expireTimer &&
|
||||||
|
!attributes.muteExpiresAt
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pushFrame({
|
this.pushFrame({
|
||||||
|
|
|
@ -1201,9 +1201,8 @@ export class BackupImportStream extends Writable {
|
||||||
|
|
||||||
this.chatIdToConvo.set(chat.id.toNumber(), conversation);
|
this.chatIdToConvo.set(chat.id.toNumber(), conversation);
|
||||||
|
|
||||||
// Make sure conversation appears in left pane
|
if (isTestEnvironment(getEnvironment())) {
|
||||||
if (conversation.active_at == null) {
|
conversation.test_chatFrameImportedFromBackup = true;
|
||||||
conversation.active_at = Math.max(chat.id.toNumber(), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conversation.isArchived = chat.archived === true;
|
conversation.isArchived = chat.archived === true;
|
||||||
|
@ -1412,14 +1411,12 @@ export class BackupImportStream extends Writable {
|
||||||
...additionalMessages.map(additional => this.saveMessage(additional)),
|
...additionalMessages.map(additional => this.saveMessage(additional)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// TODO (DESKTOP-6964): We'll want to increment for more types here - stickers, etc.
|
if (item.outgoing != null) {
|
||||||
if (item.standardMessage) {
|
chatConvo.sentMessageCount = (chatConvo.sentMessageCount ?? 0) + 1;
|
||||||
if (item.outgoing != null) {
|
} else if (item.incoming != null) {
|
||||||
chatConvo.sentMessageCount = (chatConvo.sentMessageCount ?? 0) + 1;
|
chatConvo.messageCount = (chatConvo.messageCount ?? 0) + 1;
|
||||||
} else {
|
|
||||||
chatConvo.messageCount = (chatConvo.messageCount ?? 0) + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.updateConversation(chatConvo);
|
await this.updateConversation(chatConvo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1574,6 +1571,7 @@ export class BackupImportStream extends Writable {
|
||||||
readStatus: ReadStatus.Read,
|
readStatus: ReadStatus.Read,
|
||||||
seenStatus: SeenStatus.Seen,
|
seenStatus: SeenStatus.Seen,
|
||||||
},
|
},
|
||||||
|
newActiveAt: timestamp,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,6 @@ describe('backup/integration', () => {
|
||||||
|
|
||||||
const files = readdirSync(BACKUP_INTEGRATION_DIR)
|
const files = readdirSync(BACKUP_INTEGRATION_DIR)
|
||||||
.filter(file => file.endsWith('.binproto'))
|
.filter(file => file.endsWith('.binproto'))
|
||||||
.filter(
|
|
||||||
file =>
|
|
||||||
// TODO (DESKTOP-8025)
|
|
||||||
!file.startsWith('chat_folder_') &&
|
|
||||||
!file.startsWith('notification_profile_')
|
|
||||||
)
|
|
||||||
.map(file => join(BACKUP_INTEGRATION_DIR, file));
|
.map(file => join(BACKUP_INTEGRATION_DIR, file));
|
||||||
|
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
|
@ -104,7 +98,12 @@ describe('backup/integration', () => {
|
||||||
const actualString = actual.comparableString();
|
const actualString = actual.comparableString();
|
||||||
const expectedString = expected.comparableString();
|
const expectedString = expected.comparableString();
|
||||||
|
|
||||||
if (expectedString.includes('ReleaseChannelDonationRequest')) {
|
if (
|
||||||
|
expectedString.includes('ReleaseChannelDonationRequest') ||
|
||||||
|
// TODO (DESKTOP-8025) roundtrip these frames
|
||||||
|
fullPath.includes('chat_folder') ||
|
||||||
|
fullPath.includes('notification_profile')
|
||||||
|
) {
|
||||||
// Skip the unsupported tests
|
// Skip the unsupported tests
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue