Skip to content

Commit

Permalink
Handle timer updates along with group updates
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Jul 3, 2018
1 parent 6746477 commit 9d9a797
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions js/models/conversations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -942,6 +941,7 @@
expireTimer,
source,
fromSync: options.fromSync,
fromGroupUpdate: options.fromGroupUpdate,
},
});
if (this.isPrivate()) {
Expand Down
13 changes: 10 additions & 3 deletions js/models/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,18 +641,25 @@
});
}

if (!message.isEndSession() && !message.isGroupUpdate()) {
if (!message.isEndSession()) {
if (dataMessage.expireTimer) {
if (
dataMessage.expireTimer !== conversation.get('expireTimer')
) {
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,
Expand Down
5 changes: 4 additions & 1 deletion js/views/message_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9d9a797

Please sign in to comment.