Commit 34736f8234e840203c81e10a3b49e1570aa2a801
try to fix blogIndex
mix irving committed on 11/27/2017, 11:54:01 AMParent: 587259f06bdc6df8de5db46b20722a8402b644dd
Files changed
app/html/app.js | changed |
app/html/header.js | changed |
app/html/app.mcss | added |
app/index.js | changed |
app/page/blogIndex.js | changed |
app/page/blogShow.js | changed |
app/page/settings.js | changed |
app/sync/nav-history.js | deleted |
config.js | changed |
main.js | changed |
package-lock.json | changed |
package.json | changed |
styles/global.mcss | changed |
app/html/app.js | ||
---|---|---|
@@ -1,19 +1,55 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | +const { h, Value } = require('mutant') | |
2 | 3 | |
3 | 4 | exports.gives = nest('app.html.app') |
4 | 5 | |
5 | 6 | exports.needs = nest({ |
6 | 7 | 'app.sync.initialize': 'map', |
7 | - 'app.sync.nav': 'first' | |
8 | + 'app.html.header': 'first', | |
9 | + 'history.obs.location': 'first', | |
10 | + 'history.sync.push': 'first', | |
11 | + 'router.sync.router': 'first', | |
12 | + 'settings.sync.get': 'first', | |
13 | + 'settings.sync.set': 'first', | |
8 | 14 | }) |
9 | 15 | |
10 | 16 | exports.create = (api) => { |
11 | 17 | return nest({ |
12 | 18 | 'app.html.app': function app () { |
13 | 19 | api.app.sync.initialize() |
14 | 20 | |
15 | - return api.app.sync.nav() | |
21 | + var view = Value() | |
22 | + var app = h('App', view) | |
23 | + api.history.obs.location()(renderLocation) | |
24 | + function renderLocation (loc) { | |
25 | + var page = api.router.sync.router(loc) | |
26 | + if (page) view.set([ | |
27 | + api.app.html.header({location: loc, push: api.history.sync.push}), | |
28 | + page | |
29 | + ]) | |
30 | + } | |
31 | + | |
32 | + const isOnboarded = api.settings.sync.get('onboarded') | |
33 | + if (isOnboarded) | |
34 | + api.history.sync.push({page: 'home'}) | |
35 | + else { | |
36 | + api.history.sync.push({ | |
37 | + page:'userEdit', | |
38 | + feed: api.keys.sync.id(), | |
39 | + callback: (err, didEdit) => { | |
40 | + if (err) throw new Error ('Error editing profile', err) | |
41 | + | |
42 | + if (didEdit) | |
43 | + api.settings.sync.set({ onboarded: true }) | |
44 | + | |
45 | + api.history.sync.push({ page: 'home' }) | |
46 | + } | |
47 | + }) | |
48 | + } | |
49 | + | |
50 | + | |
51 | + return app | |
16 | 52 | } |
17 | 53 | }) |
18 | 54 | } |
19 | 55 |
app/html/header.js | ||
---|---|---|
@@ -25,11 +25,10 @@ | ||
25 | 25 | |
26 | 26 | const loc = computed(location, location => { |
27 | 27 | if (typeof location != 'object') return {} |
28 | 28 | |
29 | - return location.location || {} | |
29 | + return location || {} | |
30 | 30 | }) |
31 | - // Dominics nav location api is slightly different than mine - it nest location in nav.location.location | |
32 | 31 | |
33 | 32 | const isFeed = computed(loc, loc => { |
34 | 33 | return FEED_PAGES.includes(loc.page) || (loc.key && loc.feed) |
35 | 34 | }) |
app/html/app.mcss | ||
---|---|---|
@@ -1,0 +1,8 @@ | ||
1 | +App { | |
2 | + overflow: hidden | |
3 | + position: absolute | |
4 | + top: 0 | |
5 | + bottom: 0 | |
6 | + right: 0 | |
7 | + left: 0 | |
8 | +} |
app/index.js | ||
---|---|---|
@@ -37,8 +37,7 @@ | ||
37 | 37 | clickHandler: require('./sync/initialize/clickHandler'), |
38 | 38 | styles: require('./sync/initialize/styles'), |
39 | 39 | suggests: require('./sync/initialize/suggests'), |
40 | 40 | }, |
41 | - navHistory: require('./sync/nav-history'), | |
42 | 41 | } |
43 | 42 | } |
44 | 43 |
app/page/blogIndex.js | ||
---|---|---|
@@ -18,26 +18,27 @@ | ||
18 | 18 | 'unread.sync.isUnread': 'first' |
19 | 19 | }) |
20 | 20 | |
21 | 21 | exports.create = (api) => { |
22 | - var contentHtmlObs | |
22 | + // var contentHtmlObs // TODO get a better cache than this | |
23 | 23 | |
24 | 24 | return nest('app.page.blogIndex', function (location) { |
25 | 25 | // location here can expected to be: { page: 'blogIndex'} |
26 | 26 | // |
27 | 27 | var strings = api.translations.sync.strings() |
28 | + var blogs = blogsEl() | |
28 | 29 | |
29 | 30 | return h('Page -blogIndex', {title: strings.home}, [ |
30 | 31 | api.app.html.context(location), |
31 | 32 | h('div.content', [ |
32 | 33 | h('Button -primary', { 'ev-click': () => api.history.sync.push({ page: 'blogNew' }) }, strings.blogNew.actions.writeBlog), |
33 | - blogs(), | |
34 | - h('Button -showMore', { 'ev-click': contentHtmlObs.more }, strings.showMore) | |
34 | + blogs, | |
35 | + h('Button -showMore', { 'ev-click': blogs.more }, strings.showMore) | |
35 | 36 | ]), |
36 | 37 | ]) |
37 | 38 | }) |
38 | 39 | |
39 | - function blogs () { | |
40 | + function blogsEl () { | |
40 | 41 | // TODO - replace with actual blogs |
41 | 42 | var morePlease = false |
42 | 43 | var threadsObs = api.state.obs.threads() |
43 | 44 | |
@@ -55,9 +56,10 @@ | ||
55 | 56 | requestIdleCallback(threadsObs.more) |
56 | 57 | } |
57 | 58 | |
58 | 59 | var updates = h('div.blogs', []) |
59 | - contentHtmlObs = More( | |
60 | + // contentHtmlObs = More( | |
61 | + var contentHtmlObs = More( | |
60 | 62 | threadsObsDebounced, |
61 | 63 | function render (threads) { |
62 | 64 | |
63 | 65 | function latestUpdate(thread) { |
app/page/blogShow.js | ||
---|---|---|
@@ -34,8 +34,34 @@ | ||
34 | 34 | const { lastId: branch } = api.feed.obs.thread(blogMsg.key) |
35 | 35 | |
36 | 36 | const { timeago, channel, markdown, compose } = api.message.html |
37 | 37 | |
38 | + // return api.app.html.scroller({ | |
39 | + // classList: [ 'level', '-one' ], | |
40 | + // prepend, | |
41 | + // stream: api.feed.pull.private, | |
42 | + // filter: () => pull( | |
43 | + // pull.filter(msg => msg.value.content.type === 'post'), // TODO is this the best way to protect against votes? | |
44 | + // pull.filter(msg => msg.value.author != myKey), | |
45 | + // pull.filter(msg => msg.value.content.recps) | |
46 | + // ), | |
47 | + // store: recentMsgCache, | |
48 | + // updateTop: updateRecentMsgCache, | |
49 | + // updateBottom: updateRecentMsgCache, | |
50 | + // render: (msgObs) => { | |
51 | + // const msg = resolve(msgObs) | |
52 | + // const { author } = msg.value | |
53 | + // if (nearby.has(author)) return | |
54 | + | |
55 | + // return Option({ | |
56 | + // notifications: Math.random() > 0.7 ? Math.floor(Math.random()*9+1) : 0, // TODO | |
57 | + // imageEl: api.about.html.avatar(author), | |
58 | + // label: api.about.obs.name(author), | |
59 | + // selected: location.feed === author, | |
60 | + // location: Object.assign({}, msg, { feed: author }) // TODO make obs? | |
61 | + // }) | |
62 | + // } | |
63 | + // }) | |
38 | 64 | return h('Page -blogShow', [ |
39 | 65 | api.app.html.context({ page: 'discover' }), // HACK to highlight discover |
40 | 66 | h('div.content', [ |
41 | 67 | h('header', [ |
app/page/settings.js | ||
---|---|---|
@@ -6,9 +6,9 @@ | ||
6 | 6 | exports.needs = nest({ |
7 | 7 | 'about.html.image': 'first', |
8 | 8 | 'about.obs.name': 'first', |
9 | 9 | 'history.sync.push': 'first', |
10 | - 'history.obs.history': 'first', | |
10 | + 'history.obs.store': 'first', | |
11 | 11 | 'keys.sync.id': 'first', |
12 | 12 | 'settings.sync.get': 'first', |
13 | 13 | 'settings.sync.set': 'first', |
14 | 14 | 'settings.obs.get': 'first', |
@@ -31,9 +31,9 @@ | ||
31 | 31 | // RESET the app when the settings are changed |
32 | 32 | api.settings.obs.get('language')(() => { |
33 | 33 | console.log('language changed, resetting view') |
34 | 34 | |
35 | - api.history.obs.history().set([]) // wipe nav cache | |
35 | + api.history.obs.store().set([]) // wipe nav cache | |
36 | 36 | api.history.sync.push({page: 'home'}) // queue up basic pages |
37 | 37 | api.history.sync.push({page: 'settings'}) |
38 | 38 | }) |
39 | 39 |
app/sync/nav-history.js | ||
---|---|---|
@@ -1,57 +1,0 @@ | ||
1 | -const nest = require('depnest') | |
2 | -const HyperNav = require('hyper-nav') | |
3 | -const { h } = require('mutant') | |
4 | - | |
5 | -exports.gives = nest({ | |
6 | - 'app.sync.nav': true, | |
7 | - 'history.obs.history': true, | |
8 | - 'history.sync.push': true, | |
9 | - 'history.sync.back': true, | |
10 | -}) | |
11 | - | |
12 | -exports.needs = nest({ | |
13 | - 'app.html.header': 'first', | |
14 | - 'keys.sync.id': 'first', | |
15 | - 'router.sync.router': 'first', | |
16 | - 'settings.sync.get': 'first', | |
17 | - 'settings.sync.set': 'first', | |
18 | -}) | |
19 | - | |
20 | -exports.create = (api) => { | |
21 | - var nav = null | |
22 | - | |
23 | - return nest({ | |
24 | - 'app.sync.nav': function getNav () { | |
25 | - if (nav) return nav | |
26 | - | |
27 | - nav = HyperNav( | |
28 | - api.router.sync.router, | |
29 | - api.app.html.header | |
30 | - ) | |
31 | - | |
32 | - const isOnboarded = api.settings.sync.get('onboarded') | |
33 | - if (isOnboarded) | |
34 | - nav.push({page: 'home'}) | |
35 | - else { | |
36 | - nav.push({ | |
37 | - page:'userEdit', | |
38 | - feed: api.keys.sync.id(), | |
39 | - callback: (err, didEdit) => { | |
40 | - if (err) throw new Error ('Error editing profile', err) | |
41 | - | |
42 | - if (didEdit) | |
43 | - api.settings.sync.set({ onboarded: true }) | |
44 | - | |
45 | - nav.push({ page: 'home' }) | |
46 | - } | |
47 | - }) | |
48 | - } | |
49 | - | |
50 | - return nav | |
51 | - }, | |
52 | - 'history.sync.push': (location) => nav.push(location), | |
53 | - 'history.sync.back': () => nav.back(), | |
54 | - 'history.obs.history': () => nav.history, | |
55 | - }) | |
56 | -} | |
57 | - |
config.js | ||
---|---|---|
@@ -2,9 +2,10 @@ | ||
2 | 2 | const nest = require('depnest') |
3 | 3 | const ssbKeys = require('ssb-keys') |
4 | 4 | const Path = require('path') |
5 | 5 | |
6 | -const appName = process.env.ssb_appname || 'ticktack' //'ticktack' TEMP: this is for the windowsSSB installer only | |
6 | +// const appName = process.env.ssb_appname || 'ticktack' //'ticktack' TEMP: this is for the windowsSSB installer only | |
7 | +const appName = 'ssb' | |
7 | 8 | const opts = appName == 'ssb' |
8 | 9 | ? null |
9 | 10 | : require('./default-config.json') |
10 | 11 |
main.js | ||
---|---|---|
@@ -31,8 +31,9 @@ | ||
31 | 31 | }, |
32 | 32 | { |
33 | 33 | suggestions: require('patch-suggest'), |
34 | 34 | profile: require('patch-profile'), |
35 | + history: require('patch-history'), | |
35 | 36 | core: require('patchcore') |
36 | 37 | } |
37 | 38 | ) |
38 | 39 |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 203359 bytes New file size: 208083 bytes |
package.json | ||
---|---|---|
@@ -36,8 +36,9 @@ | ||
36 | 36 | "mutant": "^3.21.2", |
37 | 37 | "mutant-scroll": "0.0.3", |
38 | 38 | "obv-debounce": "^1.0.2", |
39 | 39 | "open-external": "^0.1.1", |
40 | + "patch-history": "^1.0.0", | |
40 | 41 | "patch-profile": "^1.0.2", |
41 | 42 | "patch-settings": "^1.0.0", |
42 | 43 | "patch-suggest": "^1.0.1", |
43 | 44 | "patchcore": "^1.12.0", |
@@ -47,15 +48,15 @@ | ||
47 | 48 | "pull-scroll": "^1.0.9", |
48 | 49 | "pull-stream": "^3.6.0", |
49 | 50 | "read-directory": "^2.1.0", |
50 | 51 | "require-style": "^1.0.1", |
51 | - "scuttlebot": "^10.4.4", | |
52 | + "scuttlebot": "^10.4.10", | |
52 | 53 | "setimmediate": "^1.0.5", |
53 | 54 | "ssb-about": "^0.1.0", |
54 | 55 | "ssb-backlinks": "^0.4.0", |
55 | 56 | "ssb-blobs": "^1.1.3", |
56 | 57 | "ssb-contacts": "0.0.2", |
57 | - "ssb-friends": "^2.2.1", | |
58 | + "ssb-friends": "^2.3.5", | |
58 | 59 | "ssb-keys": "^7.0.10", |
59 | 60 | "ssb-mentions": "^0.4.0", |
60 | 61 | "ssb-private": "^0.1.2", |
61 | 62 | "ssb-query": "^0.1.2", |
Built with git-ssb-web