diff --git a/ts/background.ts b/ts/background.ts index 0796e5b90309..fb106c384711 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1932,26 +1932,6 @@ type WhatIsThis = typeof window.WhatIsThis; } } - const hasRegisteredGV23Support = 'hasRegisteredGV23Support'; - if ( - !window.storage.get(hasRegisteredGV23Support) && - window.textsecure.storage.user.getUuid() - ) { - const server = window.WebAPI.connect({ - username: USERNAME || OLD_USERNAME, - password: PASSWORD, - }); - try { - await server.registerCapabilities({ 'gv2-3': true }); - window.storage.put(hasRegisteredGV23Support, true); - } catch (error) { - window.log.error( - 'Error: Unable to register support for GV2.', - error && error.stack ? error.stack : error - ); - } - } - const deviceId = window.textsecure.storage.user.getDeviceId(); // If we didn't capture a UUID on registration, go get it from the server @@ -1980,6 +1960,27 @@ type WhatIsThis = typeof window.WhatIsThis; } } + // We need to do this after fetching our UUID + const hasRegisteredGV23Support = 'hasRegisteredGV23Support'; + if ( + !window.storage.get(hasRegisteredGV23Support) && + window.textsecure.storage.user.getUuid() + ) { + const server = window.WebAPI.connect({ + username: USERNAME || OLD_USERNAME, + password: PASSWORD, + }); + try { + await server.registerCapabilities({ 'gv2-3': true }); + window.storage.put(hasRegisteredGV23Support, true); + } catch (error) { + window.log.error( + 'Error: Unable to register support for GV2.', + error && error.stack ? error.stack : error + ); + } + } + if (firstRun === true && deviceId !== '1') { const hasThemeSetting = Boolean(window.storage.get('theme-setting')); if ( diff --git a/ts/components/ConversationListItem.tsx b/ts/components/ConversationListItem.tsx index 19a7df44069d..710f2c928563 100644 --- a/ts/components/ConversationListItem.tsx +++ b/ts/components/ConversationListItem.tsx @@ -225,13 +225,14 @@ export class ConversationListItem extends React.PureComponent { {i18n('message--deletedForEveryone')} - ) : null} - + ) : ( + + )} )} diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 94a0ab114be9..66bb597f8256 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -2985,7 +2985,7 @@ export class ConversationModel extends window.Backbone.Model< (previewMessage ? previewMessage.getMessagePropStatus() : null) || null, timestamp, lastMessageDeletedForEveryone: previewMessage - ? previewMessage.deletedForEveryone + ? previewMessage.get('deletedForEveryone') : false, }); diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 95ef6cb2bf00..af817be0e867 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -128,8 +128,6 @@ export class MessageModel extends window.Backbone.Model { OUR_UUID?: string; - deletedForEveryone?: boolean; - isSelected?: boolean; hasExpired?: boolean; @@ -1076,6 +1074,12 @@ export class MessageModel extends window.Backbone.Model { }; } + if (this.get('deletedForEveryone')) { + return { + text: window.i18n('message--deletedForEveryone'), + }; + } + if (this.isProfileChange()) { const change = this.get('profileChange'); const changedId = this.get('changedId'); @@ -1652,11 +1656,13 @@ export class MessageModel extends window.Backbone.Model { } getSourceDevice(): string | number | undefined { + const sourceDevice = this.get('sourceDevice'); + if (this.isIncoming()) { - return this.get('sourceDevice'); + return sourceDevice; } - return window.textsecure.storage.user.getDeviceId(); + return sourceDevice || window.textsecure.storage.user.getDeviceId(); } getSourceUuid(): string | undefined { diff --git a/ts/textsecure.d.ts b/ts/textsecure.d.ts index 842679d19526..33833de7ba23 100644 --- a/ts/textsecure.d.ts +++ b/ts/textsecure.d.ts @@ -1107,10 +1107,10 @@ export declare namespace SyncMessageClass { } class MessageRequestResponse { - threadE164?: string; - threadUuid?: string; - groupId?: ProtoBinaryType; - type?: number; + threadE164: string | null; + threadUuid: string | null; + groupId: ProtoBinaryType | null; + type: number | null; } } diff --git a/ts/textsecure/MessageReceiver.ts b/ts/textsecure/MessageReceiver.ts index 4295e7723f95..56035a09db71 100644 --- a/ts/textsecure/MessageReceiver.ts +++ b/ts/textsecure/MessageReceiver.ts @@ -55,7 +55,7 @@ declare global { eventType?: string | number; groupDetails?: any; groupId?: string; - messageRequestResponseType?: number; + messageRequestResponseType?: number | null; proto?: any; read?: any; reason?: any; @@ -65,8 +65,8 @@ declare global { source?: any; sourceUuid?: any; stickerPacks?: any; - threadE164?: string; - threadUuid?: string; + threadE164?: string | null; + threadUuid?: string | null; storageServiceKey?: ArrayBuffer; timestamp?: any; typing?: any; @@ -195,9 +195,6 @@ class MessageReceiverInner extends EventTarget { maxSize: 30, processBatch: this.cacheRemoveBatch.bind(this), }); - - // We always process our cache before any websocket message - this.pendingQueue.add(async () => this.queueAllCached()); } static stringToArrayBuffer = (string: string): ArrayBuffer => @@ -217,6 +214,9 @@ class MessageReceiverInner extends EventTarget { return; } + // We always process our cache before processing a new websocket message + this.pendingQueue.add(async () => this.queueAllCached()); + this.count = 0; if (this.hasConnected) { const ev = new Event('reconnect'); diff --git a/ts/textsecure/SendMessage.ts b/ts/textsecure/SendMessage.ts index 0d9e9b967079..9c3a7dc4f979 100644 --- a/ts/textsecure/SendMessage.ts +++ b/ts/textsecure/SendMessage.ts @@ -1232,8 +1232,8 @@ export default class MessageSender { const syncMessage = this.createSyncMessage(); const response = new window.textsecure.protobuf.SyncMessage.MessageRequestResponse(); - response.threadE164 = responseArgs.threadE164; - response.threadUuid = responseArgs.threadUuid; + response.threadE164 = responseArgs.threadE164 || null; + response.threadUuid = responseArgs.threadUuid || null; response.groupId = responseArgs.groupId || null; response.type = responseArgs.type; syncMessage.messageRequestResponse = response;