Commit 707b786ad8b53851c240262677d2e164cf75bf59
teach connection thing in corner to blink when new messages are saved
mixmix committed on 9/19/2018, 3:14:04 AMParent: fd8bb1c95ab59a206713bc1211f1c9c3f72e8564
Files changed
app/html/menu.js | changed |
app/html/menu.mcss | changed |
app/html/menu.js | ||
---|---|---|
@@ -1,13 +1,15 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | const { h, Value, when } = require('mutant') |
3 … | +const pull = require('pull-stream') | |
3 | 4 … | |
4 | 5 … | exports.gives = nest('app.html.menu') |
5 | 6 … | |
6 | 7 … | exports.needs = nest({ |
7 | 8 … | 'app.html.menuItem': 'map', |
8 | 9 … | 'app.sync.goTo': 'first', |
9 | - 'sbot.obs.connection': 'first' | |
10 … | + 'sbot.obs.connection': 'first', | |
11 … | + 'sbot.pull.stream': 'first' | |
10 | 12 … | }) |
11 | 13 … | |
12 | 14 … | exports.create = function (api) { |
13 | 15 … | var _menu |
@@ -16,9 +18,36 @@ | ||
16 | 18 … | if (_menu) return _menu |
17 | 19 … | |
18 | 20 … | const hoverClass = Value('') |
19 | 21 … | const connectionClass = when(api.sbot.obs.connection, '', '-disconnected') |
22 … | + const newMessageClass = Value('') | |
20 | 23 … | |
24 … | + var timeOut | |
25 … | + pull( | |
26 … | + api.sbot.pull.stream(sbot => { | |
27 … | + const query = [{ | |
28 … | + $filter: { | |
29 … | + timestamp: { $gt: 0 } | |
30 … | + } | |
31 … | + }, { | |
32 … | + $map: { | |
33 … | + author: ['value', 'author'] | |
34 … | + } | |
35 … | + }] | |
36 … | + return sbot.query.read({ live: true, old: false, query }) | |
37 … | + }), | |
38 … | + // pull.filter(a => a !== myKey), // could filter out my own messages | |
39 … | + pull.drain(m => { | |
40 … | + if (timeOut) return | |
41 … | + | |
42 … | + newMessageClass.set('-newMsg') | |
43 … | + timeOut = setTimeout(() => { | |
44 … | + newMessageClass.set('') | |
45 … | + timeOut = null | |
46 … | + }, 200) | |
47 … | + }) | |
48 … | + ) | |
49 … | + | |
21 | 50 … | const menuItems = api.app.html.menuItem(api.app.sync.goTo).map(item => { |
22 | 51 … | // Remove custom order from dependencies that give app.html.menuItem |
23 | 52 … | item.style.order = null |
24 | 53 … | return item |
@@ -28,9 +57,9 @@ | ||
28 | 57 … | ) |
29 | 58 … | |
30 | 59 … | // TODO: move goTo out into each menuItem |
31 | 60 … | _menu = h('Menu', { |
32 | - classList: [ hoverClass, connectionClass ], | |
61 … | + classList: [ hoverClass, connectionClass, newMessageClass ], | |
33 | 62 … | 'ev-mouseover': () => hoverClass.set('-open'), |
34 | 63 … | 'ev-mouseout': () => hoverClass.set('') |
35 | 64 … | }, [ |
36 | 65 … | h('div', sortedMenuItems) |
Built with git-ssb-web