git ssb

30+

cel / git-ssb-web



Commit d31cae633871e5482af52d039d74ec9f09561689

Sort notifications

cel committed on 11/30/2016, 5:03:23 PM
Parent: 37e24b25a68f741a6a265fee8d6acb0d79f7d254

Files changed

lib/index-cache.jschanged
package.jsonchanged
lib/index-cache.jsView
@@ -2,8 +2,9 @@
22 var paramap = require('pull-paramap')
33 var cat = require('pull-cat')
44 var multicb = require('multicb')
55 var ssbMsgs = require('ssb-msgs')
6 +var ssbSort = require('ssb-sort')
67 var many = require('pull-many')
78 var multicb = require('multicb')
89 var u = require('./util')
910
@@ -55,8 +56,20 @@
5556 })
5657 }
5758 }
5859
60 +function sortMsgs(obj) {
61 + // sort the notifications, but keep them in an object.
62 + // usually the javascript engine preserves the order of the keys.
63 + var out = {}
64 + ssbSort(Object.keys(obj).map(function (id) {
65 + return obj[id]
66 + })).reverse().forEach(function (msg) {
67 + out[msg.key] = msg
68 + })
69 + return out
70 +}
71 +
5972 module.exports = function (sbot, web) {
6073 var start = new Date
6174 var feedId
6275
@@ -169,8 +182,9 @@
169182 issuesPRsCb()
170183 getNewLinks()
171184 removeLinked(function () {
172185 notificationsReady = true
186 + notifications = sortMsgs(notifications)
173187 console.log('Notifications ready', (new Date - start)/1000 + 's')
174188 })
175189 })
176190 })
package.jsonView
@@ -32,8 +32,9 @@
3232 "ssb-msgs": "^5.2.0",
3333 "ssb-pull-requests": "^1.0.0",
3434 "ssb-reconnect": "^0.1.1",
3535 "ssb-ref": "^2.6.2",
36 + "ssb-sort": "^1.0.0",
3637 "stream-to-pull-stream": "^1.7.2"
3738 },
3839 "homepage": "https://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256",
3940 "bugs": "https://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256/issues",

Built with git-ssb-web