Permalink
Browse files

better explanations of why you are seeing posts in main feed

fixes #655
#498
  • Loading branch information...
mmckegg committed Dec 15, 2017
1 parent ce97eb8 commit 7cda75eab5c68ce985a6dd1154a45acc301b29ec
View
@@ -190,5 +190,11 @@
"Public Feed Options": "Public Feed Options",
"Only include posts from subscribed channels": "Only include posts from subscribed channels",
"Default": "Default",
"Force Disconnect": "Force Disconnect"
}
"Force Disconnect": "Force Disconnect",
"mentioned in your network": "mentioned in your network",
"%s people from your network replied to this message on ": {
"one": "%s person from your network replied to this message on ",
"other": "%s people from your network replied to this message on "
},
"(you)": "(you)"
}
@@ -27,6 +27,7 @@ exports.needs = nest({
'message.sync.unbox': 'first',
'message.sync.timestamp': 'first',
'profile.html.person': 'first',
'channel.html.link': 'first',
'message.html.link': 'first',
'message.sync.root': 'first',
'feed.pull.rollup': 'first',
@@ -35,6 +36,7 @@ exports.needs = nest({
'sbot.async.get': 'first',
'keys.sync.id': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n_n': 'first',
'message.html.missing': 'first'
})
@@ -44,6 +46,7 @@ exports.gives = nest({
exports.create = function (api) {
const i18n = api.intl.sync.i18n
const i18nPlural = api.intl.sync.i18n_n
return nest('feed.html.rollup', function (getStream, {
prepend,
rootFilter = returnTrue,
@@ -100,7 +103,7 @@ exports.create = function (api) {
pull.filter((msg) => {
// only render posts that have a root message
var root = msg.root || msg
return root && root.value && root.value.content && rootFilter(root) && bumpFilter(msg) && displayFilter(msg)
return root && root.value && root.value.content && rootFilter(root) && bumpFilter(msg, root) && displayFilter(msg)
}),
pull.drain((msg) => {
if (msg.value.content.type === 'vote') return
@@ -234,15 +237,32 @@ exports.create = function (api) {
unreadIds.delete(item.key)
if (!renderedMessage) return h('div')
if (lastBumpType) {
if (rootBumpType === 'matches-channel') {
var channels = []
if (item.value.content.channel) channels.push(item.value.content.channel)
if (item.filterResult && Array.isArray(item.filterResult.matchingTags)) {
item.filterResult.matchingTags.forEach(x => channels.push(x))
}
meta = h('div.meta', [
many(channels, api.channel.html.link, i18n), ' ', i18n('mentioned in your network')
])
} else if (lastBumpType) {
var bumps = lastBumpType === 'vote'
? getLikeAuthors(groupedBumps[lastBumpType])
: getAuthors(groupedBumps[lastBumpType])
var description = i18n(bumpMessages[lastBumpType] || 'added changes')
meta = h('div.meta', [
many(bumps, api.profile.html.person, i18n), ' ', description
])
if (lastBumpType === 'matches-channel' && item.value.content.channel) {
var channel = api.channel.html.link(item.value.content.channel)
meta = h('div.meta', [
i18nPlural('%s people from your network replied to this message on ', groupedBumps[lastBumpType].length), channel
])
} else {
var description = i18n(bumpMessages[lastBumpType] || 'added changes')
meta = h('div.meta', [
many(bumps, api.profile.html.person, i18n), ' ', description
])
}
}
// if there are new messages, view full thread goes to the top of those, otherwise to very first reply
@@ -266,6 +286,10 @@ exports.create = function (api) {
return result
}
function channelLink (channelName) {
return
}
function getPriority (msg) {
if (highlightItems.has(msg.key)) {
return 2
@@ -93,7 +93,12 @@ exports.create = function (api) {
if (type === 'vote') return false
var author = msg.value.author
return matchesSubscribedChannel(msg) || id === author || following().includes(author)
if (id === author || following().includes(author)) {
return true
} else if (matchesSubscribedChannel(msg)) {
return 'matches-channel'
}
}
},
rootFilter: function (msg) {
@@ -143,10 +148,14 @@ exports.create = function (api) {
}
function matchesSubscribedChannel (msg) {
var channel = api.channel.sync.normalize(msg.value.content.channel)
var tagged = checkTag(msg.value.content.mentions)
var isSubscribed = channel ? subscribedChannels().has(channel) : false
return isSubscribed || tagged
if (msg.filterResult) {
return msg.filterResult.matchesChannel || msg.filterResult.matchingTags.length
} else {
var channel = api.channel.sync.normalize(msg.value.content.channel)
var tagged = checkTag(msg.value.content.mentions)
var isSubscribed = channel ? subscribedChannels().has(channel) : false
return isSubscribed || tagged
}
}
function checkTag (mentions) {
View
@@ -41,7 +41,7 @@
"mutant-pull-reduce": "^1.1.0",
"obv": "0.0.1",
"patch-settings": "~1.1.0",
"patchcore": "~1.22.2",
"patchcore": "~1.23.0",
"pull-abortable": "^4.1.0",
"pull-defer": "^0.2.2",
"pull-file": "~1.0.0",
View
@@ -54,7 +54,10 @@ module.exports = function (ssb, config) {
if (filter && root && root.value && !isPrivate) {
var filterResult = filter(ids, root)
return checkReplyForcesDisplay(item) || shouldShow(filterResult, {onlySubscribedChannels})
if (checkReplyForcesDisplay(item) || shouldShow(filterResult, {onlySubscribedChannels})) {
root.filterResult = filterResult
return true
}
}
})
))
@@ -107,14 +110,16 @@ module.exports = function (ssb, config) {
// skip this item if it has already been included
if (!included.has(root.key) && filter && root && root.value && !isPrivate) {
if (checkReplyForcesDisplay(item)) {
// include this item if it has matching tags or the author is you
if (checkReplyForcesDisplay(item)) { // include this item if it has matching tags or the author is you
// update filter result so that we can display the correct bump message
root.filterResult = extend(item.filterResult, {forced: true})
included.add(root.key)
return true
} else if (!seen.has(root.key)) {
seen.add(root.key)
var filterResult = filter(ids, root)
if (shouldShow(filterResult, {onlySubscribedChannels})) {
root.filterResult = filterResult
included.add(root.key)
return true
}
@@ -125,7 +130,6 @@ module.exports = function (ssb, config) {
// MAP ROOT ITEMS
pull.map(item => {
var root = item.root || item
root.filterResult = item.filterResult
return root
})
))
@@ -191,6 +195,11 @@ module.exports = function (ssb, config) {
var matchingTags = getMatchingTags(subscriptions, ids, msg.value.content.mentions)
var isYours = ids.includes(msg.value.author)
var mentionsYou = getMentionsYou(ids, msg.value.content.mentions)
if (msg.value.author === '@u1Q+EEna+cJ+JGYppltW0hNZPAkJikVtOH5oMYZ3cEA=.ed25519') {
debugger
}
var following = checkFollowing(friends, ids, msg.value.author)
if (isYours || matchesChannel || matchingTags.length || following || mentionsYou) {
return {
@@ -0,0 +1,3 @@
ChannelLink {
border-bottom: 1px dotted;
}
@@ -0,0 +1,5 @@
ChannelLink {
border-bottom: 1px dotted;
color: #333
font-weight: bold
}

0 comments on commit 7cda75e

Please sign in to comment.