git ssb

10+

Matt McKegg / patchwork



Commit 1e3b2969c5517cbd13a47f312ed441add9c8900f

compact context messages on profile and mentions

Matt McKegg committed on 11/4/2017, 4:35:08 AM
Parent: 7d1df4ffdd84755dbe885235db2e4f16920ac892

Files changed

modules/feed/html/rollup.jschanged
modules/page/html/render/mentions.jschanged
modules/page/html/render/profile.jschanged
plugs/message/html/layout/default.jschanged
styles/dark/message.mcsschanged
styles/light/message.mcsschanged
modules/feed/html/rollup.jsView
@@ -42,8 +42,9 @@
4242 return nest('feed.html.rollup', function (getStream, {
4343 prepend,
4444 rootFilter = returnTrue,
4545 bumpFilter = returnTrue,
46+ compactFilter = returnFalse,
4647 prefiltered = false,
4748 displayFilter = returnTrue,
4849 updateStream, // override the stream used for realtime updates
4950 waitFor = true
@@ -185,11 +186,10 @@
185186
186187 var replies = item.replies.filter(isReply).sort(byAssertedTime)
187188 var replyElements = replies.filter(displayFilter).slice(-3).map((msg) => {
188189 var result = api.message.html.render(msg, {
189- inContext: true,
190- inSummary: true,
191190 previousId,
191+ compact: compactFilter(msg),
192192 priority: highlightItems.has(msg.key) ? 2 : 0
193193 })
194194 previousId = msg.key
195195 return [
@@ -199,10 +199,9 @@
199199 ]
200200 })
201201
202202 var renderedMessage = api.message.html.render(item, {
203- inContext: true,
204- includeForks: false,
203+ compact: compactFilter(item),
205204 priority: highlightItems.has(item.key) ? 2 : 0
206205 })
207206
208207 if (!renderedMessage) return h('div')
@@ -328,8 +327,12 @@
328327 function returnTrue () {
329328 return true
330329 }
331330
331+function returnFalse () {
332+ return true
333+}
334+
332335 function byAssertedTime (a, b) {
333336 return a.value.timestamp - b.value.timestamp
334337 }
335338
modules/page/html/render/mentions.jsView
@@ -12,8 +12,9 @@
1212 return nest('page.html.render', function mentions (path) {
1313 if (path !== '/mentions') return
1414 var id = api.keys.sync.id()
1515 return api.feed.html.rollup(api.feed.pull.mentions(id), {
16+ compactFilter: (msg) => !mentionFilter(msg), // compact context messages
1617 bumpFilter: mentionFilter,
1718 displayFilter: mentionFilter
1819 })
1920
modules/page/html/render/profile.jsView
@@ -197,8 +197,9 @@
197197 ])
198198
199199 var feedView = api.feed.html.rollup(api.feed.pull.profile(id), {
200200 prepend,
201+ compactFilter: (msg) => msg.value.author !== id, // show root context messages smaller
201202 displayFilter: (msg) => msg.value.author === id,
202203 rootFilter: (msg) => !contact.youBlock() && !api.message.sync.root(msg),
203204 bumpFilter: (msg) => msg.value.author === id
204205 })
plugs/message/html/layout/default.jsView
@@ -24,9 +24,9 @@
2424 exports.create = function (api) {
2525 const i18n = api.intl.sync.i18n
2626 return nest('message.html.layout', layout)
2727
28- function layout (msg, {layout, previousId, priority, content, includeReferences = false, includeForks = true}) {
28+ function layout (msg, {layout, previousId, priority, content, includeReferences = false, includeForks = true, compact = false}) {
2929 if (!(layout === undefined || layout === 'default')) return
3030
3131 var classList = ['Message']
3232 var replyInfo = null
@@ -45,8 +45,12 @@
4545 } else if (msg.value.content.project) {
4646 replyInfo = h('span', [i18n('on '), api.message.html.link(msg.value.content.project)])
4747 }
4848
49+ if (compact) {
50+ classList.push('-compact')
51+ }
52+
4953 if (priority === 2) {
5054 classList.push('-new')
5155 }
5256
@@ -65,9 +69,9 @@
6569 classList: when(expanded, null, '-truncated')
6670 }, [
6771 h('a', {
6872 href: '#',
69- 'ev-click': toggle(expanded)
73+ 'ev-click': toggleAndTrack(expanded)
7074 }, when(expanded, i18n('See less'), i18n('See more')))
7175 ])),
7276 h('div.actions', [
7377 api.message.html.action(msg)
@@ -116,14 +120,23 @@
116120 return array
117121 }
118122 }
119123
120-function toggle (param) {
124+function toggleAndTrack (param) {
121125 return {
122126 handleEvent: handleToggle,
123127 param
124128 }
125129 }
126130
127131 function handleToggle (ev) {
128132 this.param.set(!this.param())
133+ if (!this.param()) {
134+ ev.target.scrollIntoViewIfNeeded()
135+
136+ // HACK: due to a browser bug, sometimes the body gets affected!?
137+ // Why not just hack it!!!
138+ if (document.body.scrollTop > 0) {
139+ document.body.scrollTop = 0
140+ }
141+ }
129142 }
styles/dark/message.mcssView
@@ -61,8 +61,14 @@
6161 color: #777
6262 }
6363 }
6464
65+ -compact {
66+ section {
67+ max-height: 300px
68+ }
69+ }
70+
6571 -reply {
6672 header {
6773 font-size: 100%
6874 div.meta {
styles/light/message.mcssView
@@ -46,8 +46,14 @@
4646 }
4747 }
4848 }
4949
50+ -compact {
51+ section {
52+ max-height: 300px
53+ }
54+ }
55+
5056 -reply {
5157 header {
5258 font-size: 100%
5359 div.meta {
@@ -205,9 +211,9 @@
205211 margin: 0
206212 padding: 0 20px
207213 max-height: 1500vh
208214 overflow: hidden
209-
215+
210216 (img) {
211217 max-width: 100%
212218 }
213219

Built with git-ssb-web