git ssb

2+

mixmix / ticktack



Commit 31dca712149ea746e5ee65adb698bb4ce4a82c4e

factor out thread-card.mcss , add private messages to profile

mix irving committed on 8/16/2017, 5:50:28 AM
Parent: 99dc6aa464a4c1cc228a6af744517def76da134f

Files changed

app/html/thread-card.jschanged
app/html/thread-card.mcssadded
app/page/home.jschanged
app/page/home.mcsschanged
app/page/userShow.jschanged
app/html/thread-card.jsView
@@ -88,9 +88,9 @@
8888 const onClick = opts.onClick || function () { api.history.sync.push(thread) }
8989 const id = `${thread.key}-${JSON.stringify(opts)}`
9090 // id is only here to help morphdom morph accurately
9191
92- return h('div.thread', { 'ev-click': onClick, id }, [
92+ return h('ThreadCard', { 'ev-click': onClick, id }, [
9393 h('div.context', threadIcon(thread)),
9494 h('div.content', [
9595 subjectEl,
9696 replySample ? h('div.reply', [
app/html/thread-card.mcssView
@@ -1,0 +1,42 @@
1+ThreadCard {
2+ display: flex
3+ align-items: center
4+
5+ margin-bottom: .5rem
6+
7+ div.context {
8+ display: flex
9+ margin-right: 1rem
10+
11+ img {
12+ $smallAvatar
13+ margin-right: .5rem
14+ }
15+ }
16+
17+ div.content {
18+ flex-grow: 1
19+ background: #fff
20+ padding: 1rem
21+ border: 1px solid #ddd
22+ border-radius: 2px
23+
24+ div.subject {
25+ font-size: 1.2rem
26+ margin-bottom: .3rem
27+
28+ $largeMarkdown
29+ }
30+ div.reply {
31+ display: flex
32+ color: #444
33+
34+ div.replySymbol {
35+ margin-left: .7rem
36+ margin-right: .3rem
37+ }
38+
39+ $smallMarkdown
40+ }
41+ }
42+}
app/page/home.jsView
@@ -30,9 +30,8 @@
3030 return nest('app.page.home', function (location) {
3131 // location here can expected to be: { page: 'home' }
3232 var strings = api.translations.sync.strings()
3333
34- var container = h('div.container', [])
3534
3635 // function filterForThread (thread) {
3736 // if(thread.value.private)
3837 // return {private: toRecpGroup(thread)}
@@ -69,8 +68,9 @@
6968 morePlease = true
7069 requestIdleCallback(threadsObs.more)
7170 }
7271
72+ var container = h('div.container', [])
7373 var threadsHtmlObs = More(
7474 threadsObsDebounced,
7575 function render (threads) {
7676
@@ -106,21 +106,19 @@
106106 h('div.container', [
107107 //private section
108108 h('section.updates -directMessage', [
109109 h('div.threads',
110- groupedThreads
111- .map(function (thread) {
110+ groupedThreads.map(thread => {
111+ const channel = thread.value.content.channel
112+ const onClick = channel
113+ ? (ev) => api.history.sync.push({ channel })
114+ : null // threadCard will install default onClick
112115
113- const channel = thread.value.content.channel
114- const onClick = channel
115- ? (ev) => api.history.sync.push({ channel })
116- : null // threadCard will install default onClick
117-
118- return api.app.html.threadCard(thread, { onClick })
116+ return api.app.html.threadCard(thread, { onClick })
119117 })
120118 )
121- ]),
122- ])
119+ ])
120+ ])
123121 )
124122
125123 return container
126124 }
app/page/home.mcssView
@@ -9,9 +9,9 @@
99 -directMessage {
1010 $homePageSection
1111
1212 div.threads {
13- div.thread {
13+ div.ThreadCard {
1414 div.content {
1515 div.subject {
1616 display: flex
1717
@@ -33,9 +33,9 @@
3333 -channel {
3434 $homePageSection
3535
3636 div.threads {
37- div.thread {
37+ div.ThreadCard {
3838 div.context {
3939 background: #fff
4040 min-width: 8rem
4141 padding: .1rem .3rem
@@ -73,48 +73,7 @@
7373 margin-bottom: .4rem
7474 }
7575
7676 div.threads {
77- div.thread {
78- display: flex
79- align-items: center
80-
81- margin-bottom: .5rem
82-
83- div.context {
84- display: flex
85- margin-right: 1rem
86-
87- img {
88- $smallAvatar
89- margin-right: .5rem
90- }
91- }
92-
93- div.content {
94- flex-grow: 1
95- background: #fff
96- padding: 1rem
97- border: 1px solid #ddd
98- border-radius: 2px
99-
100- div.subject {
101- font-size: 1.2rem
102- margin-bottom: .3rem
103-
104- $largeMarkdown
105- }
106- div.reply {
107- display: flex
108- color: #444
109-
110- div.replySymbol {
111- margin-left: .7rem
112- margin-right: .3rem
113- }
114-
115- $smallMarkdown
116- }
117- }
118- }
77+ div.ThreadCard {}
11978 }
12079 }
app/page/userShow.jsView
@@ -1,18 +1,24 @@
11 const nest = require('depnest')
2-const { h, computed, when } = require('mutant')
2+const { h, Array: MutantArray, computed, when, map } = require('mutant')
3+const pull = require('pull-stream')
4+const get = require('lodash/get')
35
46 exports.gives = nest('app.page.userShow')
57
68 exports.needs = nest({
79 'app.html.link': 'first',
810 'app.html.nav': 'first',
11+ 'app.html.threadCard': 'first',
912 'about.html.image': 'first',
1013 'about.obs.name': 'first',
1114 'contact.async.follow': 'first',
1215 'contact.async.unfollow': 'first',
1316 'contact.obs.followers': 'first',
17+ 'feed.pull.private': 'first',
18+ 'feed.pull.rollup': 'first',
1419 'keys.sync.id': 'first',
20+ 'state.obs.threads': 'first',
1521 'translations.sync.strings': 'first',
1622 })
1723
1824 exports.create = (api) => {
@@ -47,8 +53,27 @@
4753 ),
4854 h('Button', { disabled: 'disabled' }, strings.loading )
4955 )
5056
57+
58+ const threads = MutantArray()
59+ pull(
60+ // next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
61+ // api.feed.pull.private({reverse: true, limit: 100, live: false}),
62+ api.feed.pull.private({reverse: true, live: false}),
63+ pull.filter(msg => {
64+ const recps = get(msg, 'value.content.recps')
65+ if (!recps) return
66+
67+ return recps
68+ .map(r => typeof r === 'object' ? r.link : r)
69+ .includes(feed)
70+ }),
71+ api.feed.pull.rollup(),
72+ pull.drain(threads.push)
73+ // Scroller(container, content, render, false, false)
74+ )
75+
5176 const Link = api.app.html.link
5277
5378 return h('Page -userShow', [
5479 api.app.html.nav(),
@@ -60,13 +85,13 @@
6085 h('div.state', ourRelationship),
6186 followButton
6287 ]) : '',
6388 h('div', '...friends in common'),
64- h('div', '...groups dominic is in'),
89+ h('div', '...groups this person is in'),
6590 feed !== myId
6691 ? Link({ page: 'threadNew', feed }, h('Button -primary', strings.userShow.action.directMessage))
6792 : '',
68- h('div', 'conversations you\'ve had with dominic'),
93+ h('div.threads', map(threads, api.app.html.threadCard))
6994 ])
7095 ])
7196 }
7297 }

Built with git-ssb-web