Commit 4847a139bc534508558e7f8744c286642ea33a5d
normalize subscribed list, expose normalizeChannel from ssb-ref
Matt McKegg committed on 11/20/2017, 3:22:24 AMParent: c2515fc07d5df937b0ab574f42b22ed788831215
Files changed
channel/obs/subscribed.js | changed |
channel/sync/normalize.js | added |
feed/pull/channel.js | changed |
package.json | changed |
channel/obs/subscribed.js | ||
---|---|---|
@@ -6,9 +6,10 @@ | ||
6 | 6 … | |
7 | 7 … | var throttle = require('mutant/throttle') |
8 | 8 … | |
9 | 9 … | exports.needs = nest({ |
10 | - 'sbot.pull.userFeed': 'first' | |
10 … | + 'sbot.pull.userFeed': 'first', | |
11 … | + 'channel.sync.normalize': 'first' | |
11 | 12 … | }) |
12 | 13 … | |
13 | 14 … | exports.gives = nest({ |
14 | 15 … | 'channel.obs.subscribed': true, |
@@ -46,9 +47,9 @@ | ||
46 | 47 … | |
47 | 48 … | var result = MutantPullReduce(stream, (result, msg) => { |
48 | 49 … | var c = msg.value.content |
49 | 50 … | if (c.type === 'channel' && typeof c.channel === 'string') { |
50 | - var channel = c.channel.trim() | |
51 … | + var channel = api.channel.sync.normalize(c.channel) | |
51 | 52 … | if (channel && msg.value.timestamp > (latestTimestamps[channel] || 0)) { |
52 | 53 … | if (channel) { |
53 | 54 … | if (typeof c.subscribed === 'boolean') { |
54 | 55 … | latestTimestamps[channel] = msg.value.timestamp |
channel/sync/normalize.js | ||
---|---|---|
@@ -1,0 +1,8 @@ | ||
1 … | +var nest = require('depnest') | |
2 … | +var normalizeChannel = require('ssb-ref').normalizeChannel | |
3 … | + | |
4 … | +exports.gives = nest('channel.sync.normalize') | |
5 … | + | |
6 … | +exports.create = function (api) { | |
7 … | + return nest('channel.sync.normalize', normalizeChannel) | |
8 … | +} |
feed/pull/channel.js | ||
---|---|---|
@@ -4,13 +4,15 @@ | ||
4 | 4 … | |
5 | 5 … | exports.gives = nest('feed.pull.channel') |
6 | 6 … | exports.needs = nest({ |
7 | 7 … | 'sbot.pull.backlinks': 'first', |
8 … | + 'channel.sync.normalize': 'first', | |
8 | 9 … | 'message.sync.isBlocked': 'first' |
9 | 10 … | }) |
10 | 11 … | |
11 | 12 … | exports.create = function (api) { |
12 | 13 … | return nest('feed.pull.channel', function (channel) { |
14 … | + channel = api.channel.sync.normalize(channel) | |
13 | 15 … | if (typeof channel !== 'string') throw new Error('a channel name be specified') |
14 | 16 … | |
15 | 17 … | return function (opts) { |
16 | 18 … | // handle last item passed in as lt |
Built with git-ssb-web