Sort by inbox position to match phone after link

This commit is contained in:
Josh Perez 2020-03-09 17:43:09 -07:00 committed by Scott Nonnenberg
parent 1f5cb9e8af
commit 4830213a12
25 changed files with 707 additions and 1029 deletions

View file

@ -1975,6 +1975,7 @@
name: details.name,
color: details.color,
active_at: activeAt,
inbox_position: details.inboxPosition,
});
// Update the conversation avatar only if new avatar exists and hash differs
@ -2030,6 +2031,14 @@
verifiedEvent.viaContactSync = true;
await onVerified(verifiedEvent);
}
const { appView } = window.owsDesktopApp;
if (appView && appView.installView && appView.installView.didLink) {
window.log.info(
'onContactReceived: Adding the message history disclaimer on link'
);
await conversation.addMessageHistoryDisclaimer();
}
} catch (error) {
window.log.error('onContactReceived error:', Errors.toLogFormat(error));
}
@ -2063,6 +2072,7 @@
members,
color: details.color,
type: 'group',
inbox_position: details.inboxPosition,
};
if (details.active) {
@ -2103,6 +2113,13 @@
window.Signal.Data.updateConversation(id, conversation.attributes);
const { appView } = window.owsDesktopApp;
if (appView && appView.installView && appView.installView.didLink) {
window.log.info(
'onGroupReceived: Adding the message history disclaimer on link'
);
await conversation.addMessageHistoryDisclaimer();
}
const { expireTimer } = details;
const isValidExpireTimer = typeof expireTimer === 'number';
if (!isValidExpireTimer) {

View file

@ -385,6 +385,7 @@
const draftText = this.get('draft');
const shouldShowDraft =
this.hasDraft() && draftTimestamp && draftTimestamp >= timestamp;
const inboxPosition = this.get('inbox_position');
const result = {
id: this.id,
@ -400,6 +401,7 @@
name: this.getName(),
profileName: this.getProfileName(),
timestamp,
inboxPosition,
title: this.getTitle(),
unreadCount: this.get('unreadCount') || 0,
@ -1662,6 +1664,38 @@
return message;
},
async addMessageHistoryDisclaimer() {
const timestamp = Date.now();
const model = new Whisper.Message({
type: 'message-history-unsynced',
// Even though this isn't reflected to the user, we want to place the last seen
// indicator above it. We set it to 'unread' to trigger that placement.
unread: 1,
conversationId: this.id,
// No type; 'incoming' messages are specially treated by conversation.markRead()
sent_at: timestamp,
received_at: timestamp,
});
if (this.isPrivate()) {
model.set({ destination: this.id });
}
if (model.isOutgoing()) {
model.set({ recipients: this.getRecipients() });
}
const id = await window.Signal.Data.saveMessage(model.attributes, {
Message: Whisper.Message,
});
model.set({ id });
const message = MessageController.register(id, model);
this.addSingleMessage(message);
return message;
},
isSearchable() {
return !this.get('left');
},

View file

@ -134,6 +134,7 @@
!this.isUnsupportedMessage() &&
!this.isExpirationTimerUpdate() &&
!this.isKeyChange() &&
!this.isMessageHistoryUnsynced() &&
!this.isVerifiedChange() &&
!this.isGroupUpdate() &&
!this.isEndSession()
@ -147,6 +148,11 @@
type: 'unsupportedMessage',
data: this.getPropsForUnsupportedMessage(),
};
} else if (this.isMessageHistoryUnsynced()) {
return {
type: 'linkNotification',
data: null,
};
} else if (this.isExpirationTimerUpdate()) {
return {
type: 'timerNotification',
@ -343,6 +349,9 @@
isVerifiedChange() {
return this.get('type') === 'verified-change';
},
isMessageHistoryUnsynced() {
return this.get('type') === 'message-history-unsynced';
},
isGroupUpdate() {
return !!this.get('group_update');
},

View file

@ -32,6 +32,7 @@
initialize(options = {}) {
window.readyForUpdates();
this.didLink = false;
this.selectStep(Steps.SCAN_QR_CODE);
this.connect();
this.on('disconnected', this.reconnect);
@ -179,7 +180,10 @@
this.selectStep(Steps.PROGRESS_BAR);
const finish = () => resolve(name);
const finish = () => {
this.didLink = true;
return resolve(name);
};
// Delete all data from database unless we're in the middle
// of a re-link, or we are finishing a light import. Without this,