git ssb

2+

mixmix / ticktack



Commit 34736f8234e840203c81e10a3b49e1570aa2a801

try to fix blogIndex

mix irving committed on 11/27/2017, 11:54:01 AM
Parent: 587259f06bdc6df8de5db46b20722a8402b644dd

Files changed

app/html/app.jschanged
app/html/header.jschanged
app/html/app.mcssadded
app/index.jschanged
app/page/blogIndex.jschanged
app/page/blogShow.jschanged
app/page/settings.jschanged
app/sync/nav-history.jsdeleted
config.jschanged
main.jschanged
package-lock.jsonchanged
package.jsonchanged
styles/global.mcsschanged
app/html/app.jsView
@@ -1,19 +1,55 @@
11 const nest = require('depnest')
2+const { h, Value } = require('mutant')
23
34 exports.gives = nest('app.html.app')
45
56 exports.needs = nest({
67 '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',
814 })
915
1016 exports.create = (api) => {
1117 return nest({
1218 'app.html.app': function app () {
1319 api.app.sync.initialize()
1420
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
1652 }
1753 })
1854 }
1955
app/html/header.jsView
@@ -25,11 +25,10 @@
2525
2626 const loc = computed(location, location => {
2727 if (typeof location != 'object') return {}
2828
29- return location.location || {}
29+ return location || {}
3030 })
31- // Dominics nav location api is slightly different than mine - it nest location in nav.location.location
3231
3332 const isFeed = computed(loc, loc => {
3433 return FEED_PAGES.includes(loc.page) || (loc.key && loc.feed)
3534 })
app/html/app.mcssView
@@ -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.jsView
@@ -37,8 +37,7 @@
3737 clickHandler: require('./sync/initialize/clickHandler'),
3838 styles: require('./sync/initialize/styles'),
3939 suggests: require('./sync/initialize/suggests'),
4040 },
41- navHistory: require('./sync/nav-history'),
4241 }
4342 }
4443
app/page/blogIndex.jsView
@@ -18,26 +18,27 @@
1818 'unread.sync.isUnread': 'first'
1919 })
2020
2121 exports.create = (api) => {
22- var contentHtmlObs
22+ // var contentHtmlObs // TODO get a better cache than this
2323
2424 return nest('app.page.blogIndex', function (location) {
2525 // location here can expected to be: { page: 'blogIndex'}
2626 //
2727 var strings = api.translations.sync.strings()
28+ var blogs = blogsEl()
2829
2930 return h('Page -blogIndex', {title: strings.home}, [
3031 api.app.html.context(location),
3132 h('div.content', [
3233 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)
3536 ]),
3637 ])
3738 })
3839
39- function blogs () {
40+ function blogsEl () {
4041 // TODO - replace with actual blogs
4142 var morePlease = false
4243 var threadsObs = api.state.obs.threads()
4344
@@ -55,9 +56,10 @@
5556 requestIdleCallback(threadsObs.more)
5657 }
5758
5859 var updates = h('div.blogs', [])
59- contentHtmlObs = More(
60+ // contentHtmlObs = More(
61+ var contentHtmlObs = More(
6062 threadsObsDebounced,
6163 function render (threads) {
6264
6365 function latestUpdate(thread) {
app/page/blogShow.jsView
@@ -34,8 +34,34 @@
3434 const { lastId: branch } = api.feed.obs.thread(blogMsg.key)
3535
3636 const { timeago, channel, markdown, compose } = api.message.html
3737
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+ // })
3864 return h('Page -blogShow', [
3965 api.app.html.context({ page: 'discover' }), // HACK to highlight discover
4066 h('div.content', [
4167 h('header', [
app/page/settings.jsView
@@ -6,9 +6,9 @@
66 exports.needs = nest({
77 'about.html.image': 'first',
88 'about.obs.name': 'first',
99 'history.sync.push': 'first',
10- 'history.obs.history': 'first',
10+ 'history.obs.store': 'first',
1111 'keys.sync.id': 'first',
1212 'settings.sync.get': 'first',
1313 'settings.sync.set': 'first',
1414 'settings.obs.get': 'first',
@@ -31,9 +31,9 @@
3131 // RESET the app when the settings are changed
3232 api.settings.obs.get('language')(() => {
3333 console.log('language changed, resetting view')
3434
35- api.history.obs.history().set([]) // wipe nav cache
35+ api.history.obs.store().set([]) // wipe nav cache
3636 api.history.sync.push({page: 'home'}) // queue up basic pages
3737 api.history.sync.push({page: 'settings'})
3838 })
3939
app/sync/nav-history.jsView
@@ -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.jsView
@@ -2,9 +2,10 @@
22 const nest = require('depnest')
33 const ssbKeys = require('ssb-keys')
44 const Path = require('path')
55
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'
78 const opts = appName == 'ssb'
89 ? null
910 : require('./default-config.json')
1011
main.jsView
@@ -31,8 +31,9 @@
3131 },
3232 {
3333 suggestions: require('patch-suggest'),
3434 profile: require('patch-profile'),
35+ history: require('patch-history'),
3536 core: require('patchcore')
3637 }
3738 )
3839
package-lock.jsonView
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.jsonView
@@ -36,8 +36,9 @@
3636 "mutant": "^3.21.2",
3737 "mutant-scroll": "0.0.3",
3838 "obv-debounce": "^1.0.2",
3939 "open-external": "^0.1.1",
40+ "patch-history": "^1.0.0",
4041 "patch-profile": "^1.0.2",
4142 "patch-settings": "^1.0.0",
4243 "patch-suggest": "^1.0.1",
4344 "patchcore": "^1.12.0",
@@ -47,15 +48,15 @@
4748 "pull-scroll": "^1.0.9",
4849 "pull-stream": "^3.6.0",
4950 "read-directory": "^2.1.0",
5051 "require-style": "^1.0.1",
51- "scuttlebot": "^10.4.4",
52+ "scuttlebot": "^10.4.10",
5253 "setimmediate": "^1.0.5",
5354 "ssb-about": "^0.1.0",
5455 "ssb-backlinks": "^0.4.0",
5556 "ssb-blobs": "^1.1.3",
5657 "ssb-contacts": "0.0.2",
57- "ssb-friends": "^2.2.1",
58+ "ssb-friends": "^2.3.5",
5859 "ssb-keys": "^7.0.10",
5960 "ssb-mentions": "^0.4.0",
6061 "ssb-private": "^0.1.2",
6162 "ssb-query": "^0.1.2",
styles/global.mcssView
@@ -3,19 +3,9 @@
33 $backgroundPrimaryText
44
55 margin: 0
66
7- // different to Page
8- div.page {
97
10- overflow: hidden
11- position: absolute
12- top: 0
13- bottom: 0
14- right: 0
15- left: 0
16- }
17-
188 (a) {
199 color: #2f63ad
2010 text-decoration: none
2111

Built with git-ssb-web