Permalink
Browse files

compact context messages on profile and mentions

  • Loading branch information...
mmckegg committed Nov 4, 2017
1 parent 7d1df4f commit 1e3b2969c5517cbd13a47f312ed441add9c8900f
@@ -43,6 +43,7 @@ exports.create = function (api) {
prepend,
rootFilter = returnTrue,
bumpFilter = returnTrue,
compactFilter = returnFalse,
prefiltered = false,
displayFilter = returnTrue,
updateStream, // override the stream used for realtime updates
@@ -186,9 +187,8 @@ exports.create = function (api) {
var replies = item.replies.filter(isReply).sort(byAssertedTime)
var replyElements = replies.filter(displayFilter).slice(-3).map((msg) => {
var result = api.message.html.render(msg, {
inContext: true,
inSummary: true,
previousId,
compact: compactFilter(msg),
priority: highlightItems.has(msg.key) ? 2 : 0
})
previousId = msg.key
@@ -200,8 +200,7 @@ exports.create = function (api) {
})
var renderedMessage = api.message.html.render(item, {
inContext: true,
includeForks: false,
compact: compactFilter(item),
priority: highlightItems.has(item.key) ? 2 : 0
})
@@ -329,6 +328,10 @@ function returnTrue () {
return true
}
function returnFalse () {
return true
}
function byAssertedTime (a, b) {
return a.value.timestamp - b.value.timestamp
}
@@ -13,6 +13,7 @@ exports.create = function (api) {
if (path !== '/mentions') return
var id = api.keys.sync.id()
return api.feed.html.rollup(api.feed.pull.mentions(id), {
compactFilter: (msg) => !mentionFilter(msg), // compact context messages
bumpFilter: mentionFilter,
displayFilter: mentionFilter
})
@@ -198,6 +198,7 @@ exports.create = function (api) {
var feedView = api.feed.html.rollup(api.feed.pull.profile(id), {
prepend,
compactFilter: (msg) => msg.value.author !== id, // show root context messages smaller
displayFilter: (msg) => msg.value.author === id,
rootFilter: (msg) => !contact.youBlock() && !api.message.sync.root(msg),
bumpFilter: (msg) => msg.value.author === id
@@ -25,7 +25,7 @@ exports.create = function (api) {
const i18n = api.intl.sync.i18n
return nest('message.html.layout', layout)
function layout (msg, {layout, previousId, priority, content, includeReferences = false, includeForks = true}) {
function layout (msg, {layout, previousId, priority, content, includeReferences = false, includeForks = true, compact = false}) {
if (!(layout === undefined || layout === 'default')) return
var classList = ['Message']
@@ -46,6 +46,10 @@ exports.create = function (api) {
replyInfo = h('span', [i18n('on '), api.message.html.link(msg.value.content.project)])
}
if (compact) {
classList.push('-compact')
}
if (priority === 2) {
classList.push('-new')
}
@@ -66,7 +70,7 @@ exports.create = function (api) {
}, [
h('a', {
href: '#',
'ev-click': toggle(expanded)
'ev-click': toggleAndTrack(expanded)
}, when(expanded, i18n('See less'), i18n('See more')))
])),
h('div.actions', [
@@ -117,7 +121,7 @@ function last (array) {
}
}
function toggle (param) {
function toggleAndTrack (param) {
return {
handleEvent: handleToggle,
param
@@ -126,4 +130,13 @@ function toggle (param) {
function handleToggle (ev) {
this.param.set(!this.param())
if (!this.param()) {
ev.target.scrollIntoViewIfNeeded()
// HACK: due to a browser bug, sometimes the body gets affected!?
// Why not just hack it!!!
if (document.body.scrollTop > 0) {
document.body.scrollTop = 0
}
}
}
View
@@ -62,6 +62,12 @@ Message {
}
}
-compact {
section {
max-height: 300px
}
}
-reply {
header {
font-size: 100%
@@ -47,6 +47,12 @@ Message {
}
}
-compact {
section {
max-height: 300px
}
}
-reply {
header {
font-size: 100%
@@ -206,7 +212,7 @@ Message {
padding: 0 20px
max-height: 1500vh
overflow: hidden
(img) {
max-width: 100%
}

0 comments on commit 1e3b296

Please sign in to comment.