Commit c1e3521f9e2d90a0532d013640e269df8377760d
Merge branch 'master' into home_page_tweaks
mix irving committed on 8/17/2017, 4:24:06 AMParent: 5a9fd871c7f581b104a466ff3ce3d199b38541f5
Parent: bb4010a7c9d311409fb0cc0158420c2fb3daba1d
Files changed
app/html/app.js | changed |
app/index.js | changed |
app/page/channel.js | changed |
app/page/home.js | changed |
app/page/threadShow.js | changed |
app/page/userShow.js | changed |
app/page/image.js | added |
app/page/image.mcss | added |
main.js | changed |
message/async/publish.js | changed |
package-lock.json | changed |
package.json | changed |
router/sync/routes.js | changed |
state/obs.js | changed |
app/html/app.js | ||
---|---|---|
@@ -27,9 +27,9 @@ | ||
27 | 27 | h('nav', [ |
28 | 28 | h('div.back', { 'ev-click': nav.back }, '←'), |
29 | 29 | h('div', { 'ev-click': () => nav.push({page:'home'}) }, 'Home') |
30 | 30 | ]), |
31 | - h('h1', computed(nav.last, e => e.element.title)), | |
31 | + h('h1', computed(nav.location, e => e.element.title)), | |
32 | 32 | ]) |
33 | 33 | }) |
34 | 34 | |
35 | 35 | return nest({ |
app/index.js | ||
---|---|---|
@@ -10,8 +10,9 @@ | ||
10 | 10 | }, |
11 | 11 | page: { |
12 | 12 | channel: require('./page/channel'), |
13 | 13 | error: require('./page/error'), |
14 | + image: require('./page/image'), | |
14 | 15 | groupFind: require('./page/groupFind'), |
15 | 16 | groupIndex: require('./page/groupIndex'), |
16 | 17 | groupNew: require('./page/groupNew'), |
17 | 18 | groupShow: require('./page/groupShow'), |
@@ -28,4 +29,5 @@ | ||
28 | 29 | |
29 | 30 | |
30 | 31 | |
31 | 32 | |
33 | + |
app/page/channel.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | 2 | const { h, computed } = require('mutant') |
3 | 3 | const More = require('hypermore') |
4 | 4 | const morphdom = require('morphdom') |
5 | +const get = require('lodash/get') | |
5 | 6 | |
6 | 7 | exports.gives = nest('app.page.channel') |
7 | 8 | |
8 | 9 | exports.needs = nest({ |
@@ -22,39 +23,32 @@ | ||
22 | 23 | } |
23 | 24 | |
24 | 25 | exports.create = (api) => { |
25 | 26 | return nest('app.page.channel', function (location) { |
26 | - // location here can expected to be: { page: 'home' } | |
27 | + const { channel } = location | |
27 | 28 | var strings = api.translations.sync.strings() |
28 | 29 | |
29 | 30 | var container = h('div.container', []) |
30 | 31 | |
31 | - var channelObs = api.state.obs.channel(location.channel) | |
32 | + var channelObs = api.state.obs.channel(channel) | |
32 | 33 | |
33 | 34 | //disable "Show More" button when we are at the last thread. |
34 | 35 | var disableShowMore = computed([channelObs], threads => !!threads.ended) |
35 | 36 | |
36 | 37 | var threadsHtmlObs = More( |
37 | 38 | channelObs, |
38 | 39 | function render (threads) { |
39 | - | |
40 | 40 | morphdom(container, |
41 | 41 | // LEGACY: some of these containers could be removed |
42 | 42 | // but they are here to be compatible with the old MCSS. |
43 | 43 | h('div.container', [ |
44 | 44 | //private section |
45 | 45 | h('section.updates -directMessage', [ |
46 | - h('div.threads', | |
47 | - Object.keys(threads.roots) | |
48 | - .map(function (id) { | |
49 | - return threads.roots[id] | |
50 | - }) | |
51 | - .sort(function (a, b) { | |
52 | - return latestUpdate(b) - latestUpdate(a) | |
53 | - }) | |
54 | - .map(function (thread) { | |
55 | - return api.app.html.threadCard(thread) | |
56 | - }) | |
46 | + h('div.threads', Object.keys(threads.roots) | |
47 | + .map(id => threads.roots[id]) | |
48 | + .filter(thread => get(thread, 'value.content.channel') == channel) | |
49 | + .sort((a, b) => latestUpdate(b) - latestUpdate(a)) | |
50 | + .map(thread => api.app.html.threadCard(thread)) | |
57 | 51 | ) |
58 | 52 | ]) |
59 | 53 | ]) |
60 | 54 | ) |
@@ -72,5 +66,4 @@ | ||
72 | 66 | }) |
73 | 67 | } |
74 | 68 | |
75 | 69 | |
76 | - |
app/page/home.js | ||
---|---|---|
@@ -14,17 +14,17 @@ | ||
14 | 14 | 'state.obs.threads': 'first', |
15 | 15 | 'app.html.threadCard': 'first' |
16 | 16 | }) |
17 | 17 | |
18 | -function toRecpGroup(msg) { | |
19 | - //cannocialize | |
20 | - return Array.isArray(msg.value.content.repcs) && | |
21 | - msg.value.content.recps.map(function (e) { | |
22 | - return (isString(e) ? e : e.link) | |
23 | - }).sort().map(function (id) { | |
24 | - return id.substring(0, 10) | |
25 | - }).join(',') | |
26 | -} | |
18 | +// function toRecpGroup(msg) { | |
19 | +// //cannocialize | |
20 | +// return Array.isArray(msg.value.content.repcs) && | |
21 | +// msg.value.content.recps.map(function (e) { | |
22 | +// return (isString(e) ? e : e.link) | |
23 | +// }).sort().map(function (id) { | |
24 | +// return id.substring(0, 10) | |
25 | +// }).join(',') | |
26 | +// } | |
27 | 27 | |
28 | 28 | exports.create = (api) => { |
29 | 29 | return nest('app.page.home', function (location) { |
30 | 30 | // location here can expected to be: { page: 'home'} |
@@ -76,18 +76,21 @@ | ||
76 | 76 | var groupedThreads = |
77 | 77 | roots(threads.private) |
78 | 78 | .concat(roots(threads.channels)) |
79 | 79 | .concat(roots(threads.groups)) |
80 | + .filter(function (thread) { | |
81 | + return thread.value.content.recps || thread.value.content.channel | |
82 | + }) | |
80 | 83 | .sort(function (a, b) { |
81 | 84 | return latestUpdate(b) - latestUpdate(a) |
82 | 85 | }) |
83 | 86 | |
84 | 87 | function latestUpdate(thread) { |
85 | - var m = thread.timestamp | |
88 | + var m = thread.timestamp || 0 | |
86 | 89 | if(!thread.replies) return m |
87 | 90 | |
88 | 91 | for(var i = 0; i < thread.replies.length; i++) |
89 | - m = Math.max(thread.replies[i].timestamp, m) | |
92 | + m = Math.max(thread.replies[i].timestamp||0, m) | |
90 | 93 | return m |
91 | 94 | } |
92 | 95 | |
93 | 96 | function roots (r) { |
app/page/threadShow.js | ||
---|---|---|
@@ -17,9 +17,9 @@ | ||
17 | 17 | return nest('app.page.threadShow', threadShow) |
18 | 18 | |
19 | 19 | function threadShow (location) { |
20 | 20 | // location = a thread (message decorated with replies) |
21 | - const { key: root, replies, channel } = location | |
21 | + const { key: root, channel } = location | |
22 | 22 | |
23 | 23 | const thread = api.app.html.thread(root) |
24 | 24 | |
25 | 25 | const meta = { |
app/page/userShow.js | ||
---|---|---|
@@ -21,10 +21,8 @@ | ||
21 | 21 | 'translations.sync.strings': 'first', |
22 | 22 | }) |
23 | 23 | |
24 | 24 | exports.create = (api) => { |
25 | - var strings = api.translations.sync.strings() | |
26 | - | |
27 | 25 | return nest('app.page.userShow', userShow) |
28 | 26 | |
29 | 27 | function userShow (location) { |
30 | 28 |
app/page/image.js | ||
---|---|---|
@@ -1,0 +1,30 @@ | ||
1 | +const nest = require('depnest') | |
2 | +const { h } = require('mutant') | |
3 | + | |
4 | +exports.gives = nest('app.page.image') | |
5 | + | |
6 | +exports.needs = nest({ | |
7 | + 'about.html.image': 'first', | |
8 | + 'about.obs.name': 'first', | |
9 | + 'app.html.thread': 'first', | |
10 | + 'blob.sync.url': 'first' | |
11 | +}) | |
12 | + | |
13 | +exports.create = (api) => { | |
14 | + return nest('app.page.image', function (location) { | |
15 | + return h('Page -image', [ | |
16 | + h('div.container', [ | |
17 | + h('img', {src: api.blob.sync.url(location.blob || location)}) | |
18 | + ]) | |
19 | + ]) | |
20 | + }) | |
21 | +} | |
22 | + | |
23 | + | |
24 | + | |
25 | + | |
26 | + | |
27 | + | |
28 | + | |
29 | + | |
30 | + |
app/page/image.mcss | ||
---|---|---|
@@ -1,0 +1,9 @@ | ||
1 | +Page -image { | |
2 | + div.container { | |
3 | + display: flex | |
4 | + | |
5 | + img { | |
6 | + margin: 0 auto | |
7 | + } | |
8 | + } | |
9 | +} |
main.js | ||
---|---|---|
@@ -22,16 +22,27 @@ | ||
22 | 22 | router: require('./router'), |
23 | 23 | styles: require('./styles'), |
24 | 24 | state: require('./state/obs'), |
25 | 25 | }, |
26 | -// require('patch-history'), | |
27 | 26 | require('patchcore') |
28 | 27 | ) |
29 | 28 | |
30 | -const api = entry(sockets, nest('app.html.app', 'first')) | |
29 | +const api = entry(sockets, nest({ | |
30 | + 'app.html.app': 'first', | |
31 | + 'invite.async.autofollow': 'first' | |
32 | +})) | |
31 | 33 | |
32 | 34 | document.body.appendChild(api.app.html.app()) |
33 | 35 | |
36 | +api.invite.async.autofollow( | |
37 | + 'wx.larpa.net:8008:@DTNmX+4SjsgZ7xyDh5xxmNtFqa6pWi5Qtw7cE8aR9TQ=.ed25519~YIRnryeLBhtBa2il9fCWDlAIFWR37Uh63Vep0L6tk6c=', | |
38 | + function (err, follows) { | |
39 | + console.log('autofollowed', err, follows); | |
40 | +}) | |
34 | 41 | |
35 | 42 | |
36 | 43 | |
37 | 44 | |
45 | + | |
46 | + | |
47 | + | |
48 | + |
message/async/publish.js | ||
---|---|---|
@@ -1,5 +1,4 @@ | ||
1 | -const h = require('mutant/h') | |
2 | 1 | const nest = require('depnest') |
3 | 2 | |
4 | 3 | exports.needs = nest({ |
5 | 4 | 'sbot.async.publish': 'first' |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 192040 bytes New file size: 192042 bytes |
package.json | ||
---|---|---|
@@ -21,9 +21,9 @@ | ||
21 | 21 | "depject": "^4.1.1", |
22 | 22 | "depnest": "^1.3.0", |
23 | 23 | "electron-default-menu": "^1.0.1", |
24 | 24 | "electron-window-state": "^4.1.1", |
25 | - "hyper-nav": "^1.0.0", | |
25 | + "hyper-nav": "^2.0.0", | |
26 | 26 | "hypermore": "^2.0.0", |
27 | 27 | "insert-css": "^2.0.0", |
28 | 28 | "libnested": "^1.2.1", |
29 | 29 | "lodash": "^4.17.4", |
@@ -32,9 +32,9 @@ | ||
32 | 32 | "mutant": "^3.21.2", |
33 | 33 | "obv-debounce": "^1.0.2", |
34 | 34 | "open-external": "^0.1.1", |
35 | 35 | "patch-history": "^1.0.0", |
36 | - "patchcore": "^1.9.1", | |
36 | + "patchcore": "^1.10.0", | |
37 | 37 | "pull-next": "^1.0.1", |
38 | 38 | "pull-obv": "^1.3.0", |
39 | 39 | "pull-stream": "^3.6.0", |
40 | 40 | "read-directory": "^2.1.0", |
@@ -48,9 +48,9 @@ | ||
48 | 48 | "ssb-keys": "^7.0.10", |
49 | 49 | "ssb-mentions": "^0.4.0", |
50 | 50 | "ssb-private": "^0.1.2", |
51 | 51 | "ssb-query": "^0.1.2", |
52 | - "ssb-reduce-stream": "^1.0.1", | |
52 | + "ssb-reduce-stream": "^1.0.2", | |
53 | 53 | "ssb-ref": "^2.7.1", |
54 | 54 | "ssb-ws": "^1.0.3", |
55 | 55 | "suggest-box": "^2.2.3", |
56 | 56 | "url": "^0.11.0" |
router/sync/routes.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | -const { isMsg, isFeed } = require('ssb-ref') | |
2 | +const { isMsg, isFeed, isBlob } = require('ssb-ref') | |
3 | 3 | exports.gives = nest('router.sync.routes') |
4 | 4 | |
5 | 5 | exports.needs = nest({ |
6 | 6 | 'app.page.error': 'first', |
@@ -14,16 +14,18 @@ | ||
14 | 14 | 'app.page.userFind': 'first', |
15 | 15 | 'app.page.userShow': 'first', |
16 | 16 | 'app.page.threadNew': 'first', |
17 | 17 | 'app.page.threadShow': 'first', |
18 | + 'app.page.image': 'first', | |
18 | 19 | }) |
19 | 20 | |
20 | 21 | exports.create = (api) => { |
21 | 22 | return nest('router.sync.routes', (sofar = []) => { |
22 | 23 | const pages = api.app.page |
23 | 24 | // route format: [ routeValidator, routeFunction ] |
24 | 25 | |
25 | 26 | const routes = [ |
27 | + [ location => isBlob(location.blob), pages.image ], | |
26 | 28 | [ location => location.page === 'home', pages.home ], |
27 | 29 | [ location => location.channel , pages.channel ], |
28 | 30 | [ location => location.page === 'settings', pages.settings ], |
29 | 31 | |
@@ -51,12 +53,4 @@ | ||
51 | 53 | } |
52 | 54 | |
53 | 55 | |
54 | 56 | |
55 | - | |
56 | - | |
57 | - | |
58 | - | |
59 | - | |
60 | - | |
61 | - | |
62 | - |
state/obs.js | ||
---|---|---|
@@ -16,8 +16,9 @@ | ||
16 | 16 | |
17 | 17 | exports.needs = nest({ |
18 | 18 | 'message.sync.unbox': 'first', |
19 | 19 | 'sbot.pull.log': 'first', |
20 | + 'sbot.async.get': 'first', | |
20 | 21 | 'feed.pull.channel': 'first' |
21 | 22 | }) |
22 | 23 | |
23 | 24 | exports.create = function (api) { |
@@ -51,8 +52,23 @@ | ||
51 | 52 | //value recovered from localStorage |
52 | 53 | initial |
53 | 54 | ) |
54 | 55 | |
56 | + var getting = {} | |
57 | + obs(function (state) { | |
58 | + var effect = state.effect | |
59 | + if(!effect) return | |
60 | + | |
61 | + state.effect = null | |
62 | + if(getting[effect.key]) return | |
63 | + | |
64 | + getting[effect.key] = true | |
65 | + api.sbot.async.get(effect.key, (err, msg) => { | |
66 | + if (!msg) return | |
67 | + obs.set(reduce(obs.value, {key: effect.key, value: msg})) | |
68 | + }) | |
69 | + }) | |
70 | + | |
55 | 71 | //stream live messages. this *should* work. |
56 | 72 | //there is no back pressure on new events |
57 | 73 | //only a show more on the top (currently) |
58 | 74 | pull( |
@@ -61,9 +77,9 @@ | ||
61 | 77 | }), |
62 | 78 | pull.drain(function (data) { |
63 | 79 | if(data.sync) return |
64 | 80 | firstTimestamp = data.timestamp |
65 | - obs.set(reduce(threadsObs.value, data)) | |
81 | + obs.set(reduce(obs.value, data)) | |
66 | 82 | }) |
67 | 83 | ) |
68 | 84 | |
69 | 85 | return obs |
@@ -92,8 +108,9 @@ | ||
92 | 108 | // ) |
93 | 109 | |
94 | 110 | |
95 | 111 | }, |
112 | + | |
96 | 113 | 'state.obs.threads': function buildThreadObs() { |
97 | 114 | if(threadsObs) return threadsObs |
98 | 115 | |
99 | 116 | // DISABLE localStorage cache. mainly disabling this to make debugging the other stuff |
@@ -129,6 +146,4 @@ | ||
129 | 146 | }) |
130 | 147 | } |
131 | 148 | |
132 | 149 | |
133 | - | |
134 | - |
Built with git-ssb-web