Commit d31cae633871e5482af52d039d74ec9f09561689
Sort notifications
cel committed on 11/30/2016, 5:03:23 PMParent: 37e24b25a68f741a6a265fee8d6acb0d79f7d254
Files changed
lib/index-cache.js | changed |
package.json | changed |
lib/index-cache.js | ||
---|---|---|
@@ -2,8 +2,9 @@ | ||
2 | 2 … | var paramap = require('pull-paramap') |
3 | 3 … | var cat = require('pull-cat') |
4 | 4 … | var multicb = require('multicb') |
5 | 5 … | var ssbMsgs = require('ssb-msgs') |
6 … | +var ssbSort = require('ssb-sort') | |
6 | 7 … | var many = require('pull-many') |
7 | 8 … | var multicb = require('multicb') |
8 | 9 … | var u = require('./util') |
9 | 10 … | |
@@ -55,8 +56,20 @@ | ||
55 | 56 … | }) |
56 | 57 … | } |
57 | 58 … | } |
58 | 59 … | |
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 … | + | |
59 | 72 … | module.exports = function (sbot, web) { |
60 | 73 … | var start = new Date |
61 | 74 … | var feedId |
62 | 75 … | |
@@ -169,8 +182,9 @@ | ||
169 | 182 … | issuesPRsCb() |
170 | 183 … | getNewLinks() |
171 | 184 … | removeLinked(function () { |
172 | 185 … | notificationsReady = true |
186 … | + notifications = sortMsgs(notifications) | |
173 | 187 … | console.log('Notifications ready', (new Date - start)/1000 + 's') |
174 | 188 … | }) |
175 | 189 … | }) |
176 | 190 … | }) |
package.json | ||
---|---|---|
@@ -32,8 +32,9 @@ | ||
32 | 32 … | "ssb-msgs": "^5.2.0", |
33 | 33 … | "ssb-pull-requests": "^1.0.0", |
34 | 34 … | "ssb-reconnect": "^0.1.1", |
35 | 35 … | "ssb-ref": "^2.6.2", |
36 … | + "ssb-sort": "^1.0.0", | |
36 | 37 … | "stream-to-pull-stream": "^1.7.2" |
37 | 38 … | }, |
38 | 39 … | "homepage": "https://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256", |
39 | 40 … | "bugs": "https://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256/issues", |
Built with git-ssb-web