Commit 5afcd8adb631eeacf34f56504d73c1849ead71a9
throttle updating active channels
Matt McKegg committed on 3/13/2017, 5:15:39 PMParent: 2bf084d1a2228d946889b72f79b7a359765d0cbf
Files changed
modules/channel/obs/recent.js | changed |
modules/channel/obs/recent.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 … | var nest = require('depnest') |
2 | -var { Value, Dict, Struct, computed } = require('mutant') | |
2 … | +var { Value, Dict, Struct, computed, throttle } = require('mutant') | |
3 | 3 … | |
4 | 4 … | exports.gives = nest({ |
5 | 5 … | 'sbot.hook.feed': true, |
6 | 6 … | 'channel.obs.recent': true |
@@ -8,9 +8,9 @@ | ||
8 | 8 … | |
9 | 9 … | exports.create = function (api) { |
10 | 10 … | var channelsLookup = Dict() |
11 | 11 … | |
12 | - var recentChannels = computed(channelsLookup, (lookup) => { | |
12 … | + var recentChannels = computed(throttle(channelsLookup, 1000), (lookup) => { | |
13 | 13 … | var values = Object.keys(lookup).map(x => lookup[x]).sort((a, b) => b.updatedAt - a.updatedAt).map(x => x.id) |
14 | 14 … | return values |
15 | 15 … | }, {nextTick: true}) |
16 | 16 … |
Built with git-ssb-web