git ssb

16+

Dominic / patchbay



Commit 707b786ad8b53851c240262677d2e164cf75bf59

teach connection thing in corner to blink when new messages are saved

mixmix committed on 9/19/2018, 3:14:04 AM
Parent: fd8bb1c95ab59a206713bc1211f1c9c3f72e8564

Files changed

app/html/menu.jschanged
app/html/menu.mcsschanged
app/html/menu.jsView
@@ -1,13 +1,15 @@
11 const nest = require('depnest')
22 const { h, Value, when } = require('mutant')
3 +const pull = require('pull-stream')
34
45 exports.gives = nest('app.html.menu')
56
67 exports.needs = nest({
78 'app.html.menuItem': 'map',
89 'app.sync.goTo': 'first',
9- 'sbot.obs.connection': 'first'
10 + 'sbot.obs.connection': 'first',
11 + 'sbot.pull.stream': 'first'
1012 })
1113
1214 exports.create = function (api) {
1315 var _menu
@@ -16,9 +18,36 @@
1618 if (_menu) return _menu
1719
1820 const hoverClass = Value('')
1921 const connectionClass = when(api.sbot.obs.connection, '', '-disconnected')
22 + const newMessageClass = Value('')
2023
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 +
2150 const menuItems = api.app.html.menuItem(api.app.sync.goTo).map(item => {
2251 // Remove custom order from dependencies that give app.html.menuItem
2352 item.style.order = null
2453 return item
@@ -28,9 +57,9 @@
2857 )
2958
3059 // TODO: move goTo out into each menuItem
3160 _menu = h('Menu', {
32- classList: [ hoverClass, connectionClass ],
61 + classList: [ hoverClass, connectionClass, newMessageClass ],
3362 'ev-mouseover': () => hoverClass.set('-open'),
3463 'ev-mouseout': () => hoverClass.set('')
3564 }, [
3665 h('div', sortedMenuItems)
app/html/menu.mcssView
@@ -23,8 +23,12 @@
2323 flex-direction: column
2424 }
2525 }
2626
27 + -newMsg {
28 + background-color: white
29 + }
30 +
2731 -disconnected {
2832 background-color: red
2933 }
3034 }

Built with git-ssb-web