Message Requests improvements
This commit is contained in:
parent
b63291507a
commit
81cb7730a5
21 changed files with 302 additions and 263 deletions
|
@ -1885,6 +1885,11 @@
|
|||
logger: window.log,
|
||||
});
|
||||
|
||||
// Force a re-fetch here when we've processed our queue. Without this, we won't try
|
||||
// again for two hours after our first attempt. Which might have been while we were
|
||||
// offline or didn't have credentials.
|
||||
window.Signal.RemoteConfig.refreshRemoteConfig();
|
||||
|
||||
let interval = setInterval(() => {
|
||||
const view = window.owsDesktopApp.appView;
|
||||
if (view) {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
};
|
||||
|
||||
const { Util } = window.Signal;
|
||||
const { Conversation, Contact, Message } = window.Signal.Types;
|
||||
const { Contact, Message } = window.Signal.Types;
|
||||
const {
|
||||
deleteAttachmentData,
|
||||
doesAttachmentExist,
|
||||
|
@ -134,12 +134,6 @@
|
|||
this.updateLastMessage.bind(this),
|
||||
200
|
||||
);
|
||||
this.throttledUpdateSharedGroups =
|
||||
this.throttledUpdateSharedGroups ||
|
||||
_.throttle(
|
||||
this.updateSharedGroups.bind(this),
|
||||
1000 * 60 * 5 // five minutes
|
||||
);
|
||||
|
||||
this.listenTo(
|
||||
this.messageCollection,
|
||||
|
@ -175,10 +169,11 @@
|
|||
this.typingPauseTimer = null;
|
||||
|
||||
// Keep props ready
|
||||
this.generateProps = () => {
|
||||
const generateProps = () => {
|
||||
this.cachedProps = this.getProps();
|
||||
};
|
||||
this.on('change', this.generateProps);
|
||||
this.on('change', generateProps);
|
||||
generateProps();
|
||||
},
|
||||
|
||||
isMe() {
|
||||
|
@ -451,8 +446,6 @@
|
|||
getProps() {
|
||||
const color = this.getColor();
|
||||
|
||||
this.throttledUpdateSharedGroups();
|
||||
|
||||
const typingValues = _.values(this.contactTypingTimers || {});
|
||||
const typingMostRecent = _.first(_.sortBy(typingValues, 'timestamp'));
|
||||
const typingContact = typingMostRecent
|
||||
|
@ -575,15 +568,16 @@
|
|||
async handleReadAndDownloadAttachments() {
|
||||
let messages;
|
||||
do {
|
||||
const first = messages ? messages.first() : null;
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
messages = await window.Signal.Data.getOlderMessagesByConversation(
|
||||
this.get('id'),
|
||||
{
|
||||
MessageCollection: Whisper.MessageCollection,
|
||||
limit: 100,
|
||||
receivedAt: messages
|
||||
? messages.first().get('received_at')
|
||||
: undefined,
|
||||
receivedAt: first ? first.get('received_at') : null,
|
||||
messageId: first ? first.id : null,
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -959,13 +953,18 @@
|
|||
(this.get('messageCountBeforeMessageRequests') || 0) > 0;
|
||||
const hasNoMessages = (this.get('messageCount') || 0) === 0;
|
||||
|
||||
const isEmptyPrivateConvo = hasNoMessages && this.isPrivate();
|
||||
const isEmptyWhitelistedGroup =
|
||||
hasNoMessages && !this.isPrivate() && this.get('profileSharing');
|
||||
|
||||
return (
|
||||
isFromOrAddedByTrustedContact ||
|
||||
hasSentMessages ||
|
||||
hasMessagesBeforeMessageRequests ||
|
||||
// an empty conversation is the scenario where we need to rely on
|
||||
// an empty group is the scenario where we need to rely on
|
||||
// whether the profile has already been shared or not
|
||||
(hasNoMessages && this.get('profileSharing'))
|
||||
isEmptyPrivateConvo ||
|
||||
isEmptyWhitelistedGroup
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -1868,37 +1867,40 @@
|
|||
return;
|
||||
}
|
||||
|
||||
const messages = await window.Signal.Data.getOlderMessagesByConversation(
|
||||
this.id,
|
||||
{ limit: 1, MessageCollection: Whisper.MessageCollection }
|
||||
);
|
||||
const [previewMessage, activityMessage] = await Promise.all([
|
||||
window.Signal.Data.getLastConversationPreview(this.id, {
|
||||
Message: Whisper.Message,
|
||||
}),
|
||||
window.Signal.Data.getLastConversationActivity(this.id, {
|
||||
Message: Whisper.Message,
|
||||
}),
|
||||
]);
|
||||
|
||||
// This is the less-restrictive of these two fetches; if it's falsey, both will be
|
||||
if (!previewMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastMessageModel = messages.at(0);
|
||||
if (
|
||||
this.hasDraft() &&
|
||||
this.get('draftTimestamp') &&
|
||||
(!lastMessageModel ||
|
||||
lastMessageModel.get('sent_at') < this.get('draftTimestamp'))
|
||||
previewMessage.get('sent_at') < this.get('draftTimestamp')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastMessageJSON = lastMessageModel
|
||||
? lastMessageModel.toJSON()
|
||||
: null;
|
||||
const lastMessageStatusModel = lastMessageModel
|
||||
? lastMessageModel.getMessagePropStatus()
|
||||
: null;
|
||||
const lastMessageUpdate = Conversation.createLastMessageUpdate({
|
||||
currentTimestamp: this.get('timestamp') || null,
|
||||
lastMessage: lastMessageJSON,
|
||||
lastMessageStatus: lastMessageStatusModel,
|
||||
lastMessageNotificationText: lastMessageModel
|
||||
? lastMessageModel.getNotificationText()
|
||||
: null,
|
||||
const currentTimestamp = this.get('timestamp') || null;
|
||||
const timestamp = activityMessage
|
||||
? activityMessage.sent_at || currentTimestamp
|
||||
: currentTimestamp;
|
||||
|
||||
this.set({
|
||||
lastMessage: previewMessage.getNotificationText() || '',
|
||||
lastMessageStatus: previewMessage.getMessagePropStatus() || null,
|
||||
timestamp,
|
||||
lastMessageDeletedForEveryone: previewMessage.deletedForEveryone,
|
||||
});
|
||||
|
||||
this.set(lastMessageUpdate);
|
||||
window.Signal.Data.updateConversation(this.attributes);
|
||||
},
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* global crypto, window */
|
||||
|
||||
const { isFunction, isNumber } = require('lodash');
|
||||
const { createLastMessageUpdate } = require('../../../ts/types/Conversation');
|
||||
const {
|
||||
arrayBufferToBase64,
|
||||
base64ToArrayBuffer,
|
||||
|
@ -161,7 +160,7 @@ module.exports = {
|
|||
arrayBufferToBase64,
|
||||
base64ToArrayBuffer,
|
||||
computeHash,
|
||||
createLastMessageUpdate,
|
||||
|
||||
deleteExternalFiles,
|
||||
maybeUpdateAvatar,
|
||||
maybeUpdateProfileAvatar,
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
const FIVE_MINUTES = 1000 * 60 * 5;
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
const { Message, MIME, VisualAttachment } = window.Signal.Types;
|
||||
const {
|
||||
|
@ -304,9 +306,12 @@
|
|||
);
|
||||
this.model.throttledGetProfiles =
|
||||
this.model.throttledGetProfiles ||
|
||||
_.throttle(this.model.getProfiles.bind(this.model), FIVE_MINUTES);
|
||||
this.model.throttledUpdateSharedGroups =
|
||||
this.model.throttledUpdateSharedGroups ||
|
||||
_.throttle(
|
||||
this.model.getProfiles.bind(this.model),
|
||||
1000 * 60 * 5 // five minutes
|
||||
this.model.updateSharedGroups.bind(this.model),
|
||||
FIVE_MINUTES
|
||||
);
|
||||
this.debouncedMaybeGrabLinkPreview = _.debounce(
|
||||
this.maybeGrabLinkPreview.bind(this),
|
||||
|
@ -720,6 +725,7 @@
|
|||
showVisualAttachment,
|
||||
showExpiredIncomingTapToViewToast,
|
||||
showExpiredOutgoingTapToViewToast,
|
||||
updateSharedGroups: this.model.throttledUpdateSharedGroups,
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue