Skip to content

Commit

Permalink
Merge pull request #353 from wireapp/dev
Browse files Browse the repository at this point in the history
staging bump 2016-10-25
  • Loading branch information
Gregor Herdmann authored Oct 25, 2016
2 parents c4e41e7 + 52a6cc7 commit cbb92a9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
18 changes: 9 additions & 9 deletions app/page/template/partials/template-message.htm
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@
<span class="label-bold" data-bind='text: message.sender_name()'></span>
<span class="ellipsis" data-bind="text: message.caption"></span>
<span class="message-icon-ping icon-ping" data-bind="css: message.animation()"></span>
<div class="message-body-actions">
<context-menu params="entries: function() {return $parent.get_context_menu_entries($data)}, tag: 'message', data: message.id"
class="context-menu icon-more font-size-xs"
tabindex="-1"></context-menu>
<time class="time" data-bind="text: message.display_timestamp_short(), attr: {'data-timestamp': message.timestamp}"></time>
<!-- ko if: message.ephemeral_status() === z.message.EphemeralStatusType.ACTIVE -->
<ephemeral-timer class="message-ephemeral-timer" params="expires: message.expire_after_millis()"></ephemeral-timer>
<!-- /ko -->
</div>
</div>
<div class="message-body-actions">
<context-menu params="entries: function() {return $parent.get_context_menu_entries($data)}, tag: 'message', data: message.id"
class="context-menu icon-more font-size-xs"
tabindex="-1"></context-menu>
<time class="time" data-bind="text: message.display_timestamp_short(), attr: {'data-timestamp': message.timestamp}"></time>
<!-- ko if: message.ephemeral_status() === z.message.EphemeralStatusType.ACTIVE -->
<ephemeral-timer class="message-ephemeral-timer" params="expires: message.expire_after_millis()"></ephemeral-timer>
<!-- /ko -->
</div>
</div>
</script>
Expand Down
19 changes: 14 additions & 5 deletions app/script/conversation/ConversationRepository.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1399,12 +1399,21 @@ class z.conversation.ConversationRepository
###
get_ephemeral_timer: (message_et) =>
millis = message_et.expire_after_millis()
return Promise.resolve() if not _.isNumber millis

expiration_date_iso = new Date(Date.now() + millis).toISOString()
message_et.expire_after_millis expiration_date_iso
@conversation_service.update_message_in_db message_et, {expire_after_millis: expiration_date_iso}
.then -> return millis
switch message_et.ephemeral_status()
when z.message.EphemeralStatusType.TIMED_OUT
return Promise.resolve 0
when z.message.EphemeralStatusType.ACTIVE
expiration_timestamp = new Date(millis).getTime()
expires_in = expiration_timestamp - Date.now()
return Promise.resolve expires_in
when z.message.EphemeralStatusType.INACTIVE
expiration_date_iso = new Date(Date.now() + millis).toISOString()
message_et.expire_after_millis expiration_date_iso
return @conversation_service.update_message_in_db message_et, {expire_after_millis: expiration_date_iso}
.then -> return millis
else
Promise.resolve()

timeout_ephemeral_message: (conversation_et, message_et) =>
if message_et.user().is_me
Expand Down
2 changes: 1 addition & 1 deletion app/script/view_model/MessageListViewModel.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class z.ViewModel.MessageListViewModel

set_ephemeral_timer = =>
@conversation_repository.get_ephemeral_timer message_et
.then (millis) => @start_ephemeral_timer message_et, millis if millis
.then (millis) => @start_ephemeral_timer message_et, millis if millis?

if document.hasFocus()
set_ephemeral_timer()
Expand Down

0 comments on commit cbb92a9

Please sign in to comment.