diff --git a/js/devel/conversation.js b/js/devel/conversation.js index c6a7faa..1efc9fe 100644 --- a/js/devel/conversation.js +++ b/js/devel/conversation.js @@ -67,12 +67,13 @@ var Conversation = new Vue({ // Improve JS performance var msgClass = ''; var msgCount = 0; + var self = this; $.each(jsondata["conversation"], function (id, vals) { - if (vals["type"] === 1) { + if (vals["type"] == 1) { msgClass = "recv"; } - else if (vals["type"] === 2) { + else if (vals["type"] == 2) { msgClass = "sent"; } else { @@ -81,11 +82,11 @@ var Conversation = new Vue({ // Store the greater msg date for refresher // Note: we divide by 100 because number compare too large integers - if ((id / 100) > (this.lastConvMessageDate / 100)) { - this.lastConvMessageDate = id; + if ((id / 100) > (self.lastConvMessageDate / 100)) { + self.lastConvMessageDate = id; // Multiplicate ID to permit date to use it properly - this.addConversationMessage({ + self.addConversationMessage({ 'id': id, 'type': msgClass, 'date': new Date(id * 1), @@ -105,7 +106,7 @@ var Conversation = new Vue({ this.messages.push(msg); }, removeConversationMessage: function (msgId) { - var len = $scope.messages.length; + var len = this.messages.length; var self = this; for (var i = 0; i < len; i++) { var curMsg = this.messages[i]; @@ -120,6 +121,24 @@ var Conversation = new Vue({ return; } } + }, + removeConversation: function () { + var self = this; + $.post(Sms.generateURL('/delete/conversation'), {"contact": self.selectedContact.label}, function (data) { + // Reinit main window + self.selectedContact.label = ""; + self.selectedContact.opt_numbers = ""; + self.selectedContact.avatar = undefined; + ContactList.removeContact(self.selectedContact); + self.messages = []; + self.selectedContact = {}; + OC.Util.History.pushState(''); + }); + } + }, + computed: { + orderedMessages: function () { + return _.orderBy(this.messages, ['date'], ['desc']) } } }); \ No newline at end of file diff --git a/js/devel/legacy.js b/js/devel/legacy.js index 4703550..4833b45 100644 --- a/js/devel/legacy.js +++ b/js/devel/legacy.js @@ -117,21 +117,6 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' ); }; - $scope.removeConversation = function () { - $.post(Sms.generateURL('/delete/conversation'), {"contact": $scope.selectedContact.label}, function (data) { - // Reinit main window - $scope.selectedContact.label = ""; - $scope.selectedContact.opt_numbers = ""; - $scope.selectedContact.avatar = undefined; - ContactList.removeContact($scope.selectedContact); - $scope.$apply(function () { - $scope.messages = []; - }); - $scope.selectedContact.nav = ""; - OC.Util.History.pushState(''); - }); - }; - $scope.filterSms = function (query) { if (query !== $scope.lastSearch) { } diff --git a/templates/main.php b/templates/main.php index 2e963c2..132e581 100644 --- a/templates/main.php +++ b/templates/main.php @@ -25,14 +25,14 @@ use \OCA\OcSms\Lib\CountryCodes;
t('No contact found.'));?>
-
+
-
+
- +
{{ selectedContact.label | firstCharacter }}
@@ -89,19 +90,19 @@ use \OCA\OcSms\Lib\CountryCodes;
- -t('Please select a conversation from the list to load it.'));?> - - - - - - - - - +
+
t('Please select a conversation from the list to load it.'));?>
+
+
+
+
{{ message.content }}
+
+
{{ message.date | date:'medium' }}
+
+
+
- - +
+