From 5fe5872995b1e7f2b6fee858bfa15e0a71598da1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Sep 2017 11:17:39 +0200 Subject: [PATCH] Correctly handle online/offline Signed-off-by: Joas Schilling --- js/models/participant.js | 4 ++++ js/models/participantcollection.js | 5 ----- js/views/participantview.js | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/js/models/participant.js b/js/models/participant.js index 6975f5124..7b046a3b1 100644 --- a/js/models/participant.js +++ b/js/models/participant.js @@ -33,6 +33,10 @@ sessionId: '', participantType: 4, lastPing: 0 + }, + + isOnline: function() { + return this.get('lastPing') >= moment().format('X') - 60; } }); diff --git a/js/models/participantcollection.js b/js/models/participantcollection.js index ec0900119..74d19dd73 100644 --- a/js/models/participantcollection.js +++ b/js/models/participantcollection.js @@ -27,10 +27,6 @@ OCA.SpreedMe.Models = OCA.SpreedMe.Models || {}; OCA.SpreedMe.Models.ParticipantCollection = Backbone.Collection.extend({ - initialize: function() { - console.log("initialize"); - console.log(arguments); - }, model: OCA.SpreedMe.Models.Participant, room: undefined, @@ -50,7 +46,6 @@ * @returns {Array} */ parse: function(result) { - console.log(result); return result.ocs.data; } }); diff --git a/js/views/participantview.js b/js/views/participantview.js index 68b1984a7..a948cb9ef 100644 --- a/js/views/participantview.js +++ b/js/views/participantview.js @@ -30,7 +30,7 @@ var uiChannel = Backbone.Radio.channel('ui'); var ITEM_TEMPLATE = '' + - '' + + '' + '
' + ' {{displayName}}' + '{{#if participantIsOwner}}(' + t('spreed', 'moderator') + '){{/if}}' + @@ -124,7 +124,7 @@ this.$el.attr('data-session-id', this.model.get('sessionId')); this.$el.attr('data-participant', this.model.get('userId')); this.$el.addClass('participant'); - if (this.model.get('pariticipantIsOffline')) { + if (!this.model.isOnline()) { this.$el.addClass('participant-offline'); }