Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-09-04 15:10:18 +0300
committerGitHub <noreply@github.com>2017-09-04 15:10:18 +0300
commitb5ae1af6a119a2b65f58caa35e69093e6b1476d0 (patch)
tree6a1a21534b46ace2665fb4740b5a2d3503f3bccf
parent8e687f28a863b3fd0e81417229c511719c9d1102 (diff)
parent23b0b293b385ee8033ed9b4458d8e4ad16388188 (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.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/js/app.js b/js/app.js
index 912bb37..7d16292 100644
--- a/js/app.js
+++ b/js/app.js
@@ -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);
},
/**