Handle timer updates along with group updates

This commit is contained in:
Scott Nonnenberg 2018-06-25 15:58:55 -07:00
parent 67464774c3
commit 9d9a797bda
4 changed files with 18 additions and 8 deletions

View file

@ -1087,7 +1087,7 @@
},
"timerSetTo": {
"message": "Timer set to $time$",
"description": "Displayed in the conversation list when the timer is updated.",
"description": "Displayed in the conversation list when the timer is updated by some automatic action.",
"placeholders": {
"time": {
"content": "$1",

View file

@ -899,13 +899,12 @@
providedExpireTimer,
providedSource,
receivedAt,
providedOptions
options = {}
) {
const options = providedOptions || {};
let expireTimer = providedExpireTimer;
let source = providedSource;
_.defaults(options, { fromSync: false });
_.defaults(options, { fromSync: false, fromGroupUpdate: false });
if (!expireTimer) {
expireTimer = null;
@ -942,6 +941,7 @@
expireTimer,
source,
fromSync: options.fromSync,
fromGroupUpdate: options.fromGroupUpdate,
},
});
if (this.isPrivate()) {

View file

@ -641,7 +641,7 @@
});
}
if (!message.isEndSession() && !message.isGroupUpdate()) {
if (!message.isEndSession()) {
if (dataMessage.expireTimer) {
if (
dataMessage.expireTimer !== conversation.get('expireTimer')
@ -649,10 +649,17 @@
conversation.updateExpirationTimer(
dataMessage.expireTimer,
source,
message.get('received_at')
message.get('received_at'),
{
fromGroupUpdate: message.isGroupUpdate(),
}
);
}
} else if (conversation.get('expireTimer')) {
} else if (
conversation.get('expireTimer') &&
// We only turn off timers if it's not a group update
!message.isGroupUpdate()
) {
conversation.updateExpirationTimer(
null,
source,

View file

@ -103,7 +103,10 @@
const timerUpdate = this.model.get('expirationTimerUpdate');
const prettySeconds = Whisper.ExpirationTimerOptions.getName(seconds);
if (timerUpdate && timerUpdate.fromSync) {
if (
timerUpdate &&
(timerUpdate.fromSync || timerUpdate.fromGroupUpdate)
) {
timerMessage = i18n('timerSetOnSync', prettySeconds);
} else if (this.conversation.id === textsecure.storage.user.getNumber()) {
timerMessage = i18n('youChangedTheTimer', prettySeconds);