git ssb

2+

mixmix / ticktack



Commit c1e3521f9e2d90a0532d013640e269df8377760d

Merge branch 'master' into home_page_tweaks

mix irving committed on 8/17/2017, 4:24:06 AM
Parent: 5a9fd871c7f581b104a466ff3ce3d199b38541f5
Parent: bb4010a7c9d311409fb0cc0158420c2fb3daba1d

Files changed

app/html/app.jschanged
app/index.jschanged
app/page/channel.jschanged
app/page/home.jschanged
app/page/threadShow.jschanged
app/page/userShow.jschanged
app/page/image.jsadded
app/page/image.mcssadded
main.jschanged
message/async/publish.jschanged
package-lock.jsonchanged
package.jsonchanged
router/sync/routes.jschanged
state/obs.jschanged
app/html/app.jsView
@@ -27,9 +27,9 @@
2727 h('nav', [
2828 h('div.back', { 'ev-click': nav.back }, '←'),
2929 h('div', { 'ev-click': () => nav.push({page:'home'}) }, 'Home')
3030 ]),
31- h('h1', computed(nav.last, e => e.element.title)),
31+ h('h1', computed(nav.location, e => e.element.title)),
3232 ])
3333 })
3434
3535 return nest({
app/index.jsView
@@ -10,8 +10,9 @@
1010 },
1111 page: {
1212 channel: require('./page/channel'),
1313 error: require('./page/error'),
14+ image: require('./page/image'),
1415 groupFind: require('./page/groupFind'),
1516 groupIndex: require('./page/groupIndex'),
1617 groupNew: require('./page/groupNew'),
1718 groupShow: require('./page/groupShow'),
@@ -28,4 +29,5 @@
2829
2930
3031
3132
33+
app/page/channel.jsView
@@ -1,8 +1,9 @@
11 const nest = require('depnest')
22 const { h, computed } = require('mutant')
33 const More = require('hypermore')
44 const morphdom = require('morphdom')
5+const get = require('lodash/get')
56
67 exports.gives = nest('app.page.channel')
78
89 exports.needs = nest({
@@ -22,39 +23,32 @@
2223 }
2324
2425 exports.create = (api) => {
2526 return nest('app.page.channel', function (location) {
26- // location here can expected to be: { page: 'home' }
27+ const { channel } = location
2728 var strings = api.translations.sync.strings()
2829
2930 var container = h('div.container', [])
3031
31- var channelObs = api.state.obs.channel(location.channel)
32+ var channelObs = api.state.obs.channel(channel)
3233
3334 //disable "Show More" button when we are at the last thread.
3435 var disableShowMore = computed([channelObs], threads => !!threads.ended)
3536
3637 var threadsHtmlObs = More(
3738 channelObs,
3839 function render (threads) {
39-
4040 morphdom(container,
4141 // LEGACY: some of these containers could be removed
4242 // but they are here to be compatible with the old MCSS.
4343 h('div.container', [
4444 //private section
4545 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))
5751 )
5852 ])
5953 ])
6054 )
@@ -72,5 +66,4 @@
7266 })
7367 }
7468
7569
76-
app/page/home.jsView
@@ -14,17 +14,17 @@
1414 'state.obs.threads': 'first',
1515 'app.html.threadCard': 'first'
1616 })
1717
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+// }
2727
2828 exports.create = (api) => {
2929 return nest('app.page.home', function (location) {
3030 // location here can expected to be: { page: 'home'}
@@ -76,18 +76,21 @@
7676 var groupedThreads =
7777 roots(threads.private)
7878 .concat(roots(threads.channels))
7979 .concat(roots(threads.groups))
80+ .filter(function (thread) {
81+ return thread.value.content.recps || thread.value.content.channel
82+ })
8083 .sort(function (a, b) {
8184 return latestUpdate(b) - latestUpdate(a)
8285 })
8386
8487 function latestUpdate(thread) {
85- var m = thread.timestamp
88+ var m = thread.timestamp || 0
8689 if(!thread.replies) return m
8790
8891 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)
9093 return m
9194 }
9295
9396 function roots (r) {
app/page/threadShow.jsView
@@ -17,9 +17,9 @@
1717 return nest('app.page.threadShow', threadShow)
1818
1919 function threadShow (location) {
2020 // location = a thread (message decorated with replies)
21- const { key: root, replies, channel } = location
21+ const { key: root, channel } = location
2222
2323 const thread = api.app.html.thread(root)
2424
2525 const meta = {
app/page/userShow.jsView
@@ -21,10 +21,8 @@
2121 'translations.sync.strings': 'first',
2222 })
2323
2424 exports.create = (api) => {
25- var strings = api.translations.sync.strings()
26-
2725 return nest('app.page.userShow', userShow)
2826
2927 function userShow (location) {
3028
app/page/image.jsView
@@ -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.mcssView
@@ -1,0 +1,9 @@
1+Page -image {
2+ div.container {
3+ display: flex
4+
5+ img {
6+ margin: 0 auto
7+ }
8+ }
9+}
main.jsView
@@ -22,16 +22,27 @@
2222 router: require('./router'),
2323 styles: require('./styles'),
2424 state: require('./state/obs'),
2525 },
26-// require('patch-history'),
2726 require('patchcore')
2827 )
2928
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+}))
3133
3234 document.body.appendChild(api.app.html.app())
3335
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+})
3441
3542
3643
3744
45+
46+
47+
48+
message/async/publish.jsView
@@ -1,5 +1,4 @@
1-const h = require('mutant/h')
21 const nest = require('depnest')
32
43 exports.needs = nest({
54 'sbot.async.publish': 'first'
package-lock.jsonView
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.jsonView
@@ -21,9 +21,9 @@
2121 "depject": "^4.1.1",
2222 "depnest": "^1.3.0",
2323 "electron-default-menu": "^1.0.1",
2424 "electron-window-state": "^4.1.1",
25- "hyper-nav": "^1.0.0",
25+ "hyper-nav": "^2.0.0",
2626 "hypermore": "^2.0.0",
2727 "insert-css": "^2.0.0",
2828 "libnested": "^1.2.1",
2929 "lodash": "^4.17.4",
@@ -32,9 +32,9 @@
3232 "mutant": "^3.21.2",
3333 "obv-debounce": "^1.0.2",
3434 "open-external": "^0.1.1",
3535 "patch-history": "^1.0.0",
36- "patchcore": "^1.9.1",
36+ "patchcore": "^1.10.0",
3737 "pull-next": "^1.0.1",
3838 "pull-obv": "^1.3.0",
3939 "pull-stream": "^3.6.0",
4040 "read-directory": "^2.1.0",
@@ -48,9 +48,9 @@
4848 "ssb-keys": "^7.0.10",
4949 "ssb-mentions": "^0.4.0",
5050 "ssb-private": "^0.1.2",
5151 "ssb-query": "^0.1.2",
52- "ssb-reduce-stream": "^1.0.1",
52+ "ssb-reduce-stream": "^1.0.2",
5353 "ssb-ref": "^2.7.1",
5454 "ssb-ws": "^1.0.3",
5555 "suggest-box": "^2.2.3",
5656 "url": "^0.11.0"
router/sync/routes.jsView
@@ -1,6 +1,6 @@
11 const nest = require('depnest')
2-const { isMsg, isFeed } = require('ssb-ref')
2+const { isMsg, isFeed, isBlob } = require('ssb-ref')
33 exports.gives = nest('router.sync.routes')
44
55 exports.needs = nest({
66 'app.page.error': 'first',
@@ -14,16 +14,18 @@
1414 'app.page.userFind': 'first',
1515 'app.page.userShow': 'first',
1616 'app.page.threadNew': 'first',
1717 'app.page.threadShow': 'first',
18+ 'app.page.image': 'first',
1819 })
1920
2021 exports.create = (api) => {
2122 return nest('router.sync.routes', (sofar = []) => {
2223 const pages = api.app.page
2324 // route format: [ routeValidator, routeFunction ]
2425
2526 const routes = [
27+ [ location => isBlob(location.blob), pages.image ],
2628 [ location => location.page === 'home', pages.home ],
2729 [ location => location.channel , pages.channel ],
2830 [ location => location.page === 'settings', pages.settings ],
2931
@@ -51,12 +53,4 @@
5153 }
5254
5355
5456
55-
56-
57-
58-
59-
60-
61-
62-
state/obs.jsView
@@ -16,8 +16,9 @@
1616
1717 exports.needs = nest({
1818 'message.sync.unbox': 'first',
1919 'sbot.pull.log': 'first',
20+ 'sbot.async.get': 'first',
2021 'feed.pull.channel': 'first'
2122 })
2223
2324 exports.create = function (api) {
@@ -51,8 +52,23 @@
5152 //value recovered from localStorage
5253 initial
5354 )
5455
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+
5571 //stream live messages. this *should* work.
5672 //there is no back pressure on new events
5773 //only a show more on the top (currently)
5874 pull(
@@ -61,9 +77,9 @@
6177 }),
6278 pull.drain(function (data) {
6379 if(data.sync) return
6480 firstTimestamp = data.timestamp
65- obs.set(reduce(threadsObs.value, data))
81+ obs.set(reduce(obs.value, data))
6682 })
6783 )
6884
6985 return obs
@@ -92,8 +108,9 @@
92108 // )
93109
94110
95111 },
112+
96113 'state.obs.threads': function buildThreadObs() {
97114 if(threadsObs) return threadsObs
98115
99116 // DISABLE localStorage cache. mainly disabling this to make debugging the other stuff
@@ -129,6 +146,4 @@
129146 })
130147 }
131148
132149
133-
134-

Built with git-ssb-web