diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-09-04 15:10:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 15:10:18 +0300 |
commit | b5ae1af6a119a2b65f58caa35e69093e6b1476d0 (patch) | |
tree | 6a1a21534b46ace2665fb4740b5a2d3503f3bccf | |
parent | 8e687f28a863b3fd0e81417229c511719c9d1102 (diff) | |
parent | 23b0b293b385ee8033ed9b4458d8e4ad16388188 (diff) |
Merge pull request #91 from nextcloud/fix-notifications-order
Append notifications on initial fetch but prepend them on polling
-rw-r--r-- | js/app.js | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -227,7 +227,8 @@ this._fetch( function(data) { var inJson = [], - oldNum = self.numNotifications(); + oldNum = self.numNotifications(), + resort = false; _.each(data, function(notification) { var n = new self.Notification(notification); @@ -235,9 +236,18 @@ if (!self.getNotification(n.getId())) { // New notification! self._onNewNotification(n); + resort = true; } }); + if (resort) { + self.$container.find('.notification').sort(function (prev, next) { + return parseInt(next.dataset.timestamp) - parseInt(prev.dataset.timestamp); + }).each(function() { + $(self.$container.find('.notification-wrapper')).append(this); + }); + } + _.each(self.getNotifications(), function(n) { if (inJson.indexOf(n.getId()) === -1) { // Not in JSON, remove from UI @@ -381,10 +391,9 @@ var $fullMessage = $(this).parent().find('.notification-full-message'); $(this).addClass('hidden'); $fullMessage.removeClass('hidden'); - }); - this.$container.find('.notification-wrapper').prepend($element); + this.$container.find('.notification-wrapper').append($element); }, /** |