git ssb

10+

Matt McKegg / patchwork



Commit 0226ff61f37fc9d4a090da891284f7e6fa9646cc

add mentions tab

Matt McKegg committed on 2/17/2017, 2:59:53 PM
Parent: 9cef1e5a6f8635bc015c83e35effb07ad1e49ac6

Files changed

main-window.jschanged
modules/feed/html/rollup.jschanged
modules/page/html/render/mentions.jsadded
main-window.jsView
@@ -53,9 +53,9 @@
5353 // preload tabs (and subscribe to update notifications)
5454 '/public': renderPage('/public'),
5555 '/private': renderPage('/private'),
5656 [id]: renderPage(id),
57- // '/notifications': renderPage('/notifications')
57 + '/mentions': renderPage('/mentions')
5858 })
5959
6060 var lastViewed = {}
6161 var defaultViews = views.keys()
@@ -106,9 +106,9 @@
106106 h('span.appTitle', ['Patchwork']),
107107 h('span', [ searchBox ]),
108108 h('span.nav', [
109109 tab('Profile', id),
110- // tab('Mentions', '/notifications')
110 + tab('Mentions', '/mentions')
111111 ])
112112 ]),
113113 mainElement
114114 ])
modules/feed/html/rollup.jsView
@@ -147,8 +147,77 @@
147147 abortable,
148148 Scroller(container, content, renderItem, false, false)
149149 )
150150 }
151 +
152 + function renderItem (item) {
153 + if (item.type === 'message') {
154 + var meta = null
155 + var previousId = item.messageId
156 + var replies = item.replies.slice(-4).map((msg) => {
157 + var result = api.message.html.render(msg, {inContext: true, inSummary: true, previousId})
158 + previousId = msg.key
159 + return result
160 + })
161 + var renderedMessage = item.message ? api.message.html.render(item.message, {inContext: true}) : null
162 + if (renderedMessage) {
163 + if (item.lastUpdateType === 'reply' && item.repliesFrom.size) {
164 + meta = h('div.meta', {
165 + title: names(item.repliesFrom)
166 + }, [
167 + api.profile.html.manyPeople(item.repliesFrom), ' replied'
168 + ])
169 + } else if (item.lastUpdateType === 'dig' && item.digs.size) {
170 + meta = h('div.meta', {
171 + title: names(item.digs)
172 + }, [
173 + api.profile.html.manyPeople(item.digs), ' dug this message'
174 + ])
175 + }
176 +
177 + return h('FeedEvent', [
178 + meta,
179 + renderedMessage,
180 + when(replies.length, [
181 + when(item.replies.length > replies.length || opts.partial,
182 + h('a.full', {href: item.messageId}, ['View full thread'])
183 + ),
184 + h('div.replies', replies)
185 + ])
186 + ])
187 + } else {
188 + if (item.lastUpdateType === 'reply' && item.repliesFrom.size) {
189 + meta = h('div.meta', {
190 + title: names(item.repliesFrom)
191 + }, [
192 + api.profile.html.manyPeople(item.repliesFrom), ' replied to ', api.message.html.link(item.messageId)
193 + ])
194 + } else if (item.lastUpdateType === 'dig' && item.digs.size) {
195 + meta = h('div.meta', {
196 + title: names(item.digs)
197 + }, [
198 + api.profile.html.manyPeople(item.digs), ' dug ', api.message.html.link(item.messageId)
199 + ])
200 + }
201 +
202 + if (meta || replies.length) {
203 + return h('FeedEvent', [
204 + meta, h('div.replies', replies)
205 + ])
206 + }
207 + }
208 + } else if (item.type === 'follow') {
209 + return h('FeedEvent -follow', [
210 + h('div.meta', {
211 + title: names(item.contacts)
212 + }, [
213 + api.profile.html.person(item.id), ' followed ', api.profile.html.manyPeople(item.contacts)
214 + ])
215 + ])
216 + }
217 +
218 + return h('div')
219 + }
151220 }
152221
153222 function ensureAuthor (item, cb) {
154223 if (item.type === 'message' && !item.message) {
@@ -162,77 +231,8 @@
162231 cb(null, item)
163232 }
164233 }
165234
166- function renderItem (item) {
167- if (item.type === 'message') {
168- var meta = null
169- var previousId = item.messageId
170- var replies = item.replies.slice(-4).map((msg) => {
171- var result = api.message.html.render(msg, {inContext: true, inSummary: true, previousId})
172- previousId = msg.key
173- return result
174- })
175- var renderedMessage = item.message ? api.message.html.render(item.message, {inContext: true}) : null
176- if (renderedMessage) {
177- if (item.lastUpdateType === 'reply' && item.repliesFrom.size) {
178- meta = h('div.meta', {
179- title: names(item.repliesFrom)
180- }, [
181- api.profile.html.manyPeople(item.repliesFrom), ' replied'
182- ])
183- } else if (item.lastUpdateType === 'dig' && item.digs.size) {
184- meta = h('div.meta', {
185- title: names(item.digs)
186- }, [
187- api.profile.html.manyPeople(item.digs), ' dug this message'
188- ])
189- }
190-
191- return h('FeedEvent', [
192- meta,
193- renderedMessage,
194- when(replies.length, [
195- when(item.replies.length > replies.length,
196- h('a.full', {href: item.messageId}, ['View full thread'])
197- ),
198- h('div.replies', replies)
199- ])
200- ])
201- } else {
202- if (item.lastUpdateType === 'reply' && item.repliesFrom.size) {
203- meta = h('div.meta', {
204- title: names(item.repliesFrom)
205- }, [
206- api.profile.html.manyPeople(item.repliesFrom), ' replied to ', api.message.html.link(item.messageId)
207- ])
208- } else if (item.lastUpdateType === 'dig' && item.digs.size) {
209- meta = h('div.meta', {
210- title: names(item.digs)
211- }, [
212- api.profile.html.manyPeople(item.digs), ' dug ', api.message.html.link(item.messageId)
213- ])
214- }
215-
216- if (meta || replies.length) {
217- return h('FeedEvent', [
218- meta, h('div.replies', replies)
219- ])
220- }
221- }
222- } else if (item.type === 'follow') {
223- return h('FeedEvent -follow', [
224- h('div.meta', {
225- title: names(item.contacts)
226- }, [
227- api.profile.html.person(item.id), ' followed ', api.profile.html.manyPeople(item.contacts)
228- ])
229- ])
230- }
231-
232- return h('div')
233- }
234-
235235 function names (ids) {
236236 var items = map(ids, api.about.obs.name)
237237 return computed([items], (names) => names.map((n) => `- ${n}`).join('\n'))
238238 }
modules/page/html/render/mentions.jsView
@@ -1,0 +1,21 @@
1 +var { h, when } = require('mutant')
2 +var nest = require('depnest')
3 +
4 +exports.needs = nest({
5 + 'feed.html.rollup': 'first',
6 + 'keys.sync.id': 'first',
7 + 'feed.pull.mentions': 'first'
8 +})
9 +
10 +exports.gives = nest('page.html.render')
11 +
12 +exports.create = function (api) {
13 + return nest('page.html.render', function mentions (path) {
14 + if (path !== '/mentions') return
15 + var id = api.keys.sync.id()
16 + return api.feed.html.rollup(api.feed.pull.mentions(id), {
17 + windowSize: 20,
18 + partial: true
19 + })
20 + })
21 +}

Built with git-ssb-web