git ssb

10+

Matt McKegg / patchwork



Commit fb49ce16f112e37291b22b0b80e356c5a9c8e7e3

fix onlySubscribed filter

fixes #696
Matt McKegg committed on 2/12/2018, 3:59:14 AM
Parent: b6dbdef347c796b446ad6c329ec6d57e8d1f0b26

Files changed

modules/page/html/render/public.jschanged
sbot/roots.jschanged
modules/page/html/render/public.jsView
@@ -77,10 +77,9 @@
7777 // if an lt has been specified that is not a marker, assume stream is finished
7878 return pull.empty()
7979 } else {
8080 return api.sbot.pull.stream(sbot => sbot.patchwork.roots(extend(opts, {
81- ids: [id],
82- onlySubscribedChannels: filters() && filters().onlySubscribed
81+ ids: [id]
8382 })))
8483 }
8584 }
8685
@@ -149,9 +148,10 @@
149148 if (filterObj) {
150149 const rootType = getType(root)
151150 if (
152151 (filterObj.following && rootType === 'contact') ||
153- (filterObj.subscriptions && rootType === 'channel')
152+ (filterObj.subscriptions && rootType === 'channel') ||
153+ (filterObj.onlySubscribed && rootType === 'post' && !matchesSubscribedChannel(root))
154154 ) {
155155 return false
156156 }
157157 }
sbot/roots.jsView
@@ -25,9 +25,9 @@
2525 // not really big enough for multiple refresh cycles
2626 var cache = HLRU(100)
2727
2828 return {
29- latest: function ({ids = [ssb.id], onlySubscribedChannels = false}) {
29+ latest: function ({ids = [ssb.id]}) {
3030 var stream = Defer.source()
3131 getFilter((err, filter) => {
3232 if (err) return stream.abort(err)
3333 stream.resolve(pull(
@@ -53,9 +53,9 @@
5353 var isPrivate = root.value && typeof root.value.content === 'string'
5454
5555 if (filter && root && root.value && !isPrivate) {
5656 var filterResult = filter(ids, root)
57- if (checkReplyForcesDisplay(item) || shouldShow(filterResult, {onlySubscribedChannels})) {
57+ if (checkReplyForcesDisplay(item) || shouldShow(filterResult)) {
5858 root.filterResult = filterResult
5959 return true
6060 }
6161 }
@@ -64,9 +64,9 @@
6464 })
6565 return stream
6666 },
6767
68- read: function ({ids = [ssb.id], reverse, limit, lt, gt, onlySubscribedChannels = false}) {
68+ read: function ({ids = [ssb.id], reverse, limit, lt, gt}) {
6969 var opts = {reverse, old: true}
7070
7171 // handle markers passed in to lt / gt
7272 if (lt && typeof lt.timestamp === 'number') lt = lt.timestamp
@@ -117,9 +117,9 @@
117117 return true
118118 } else if (!seen.has(root.key)) {
119119 seen.add(root.key)
120120 var filterResult = filter(ids, root)
121- if (shouldShow(filterResult, {onlySubscribedChannels})) {
121+ if (shouldShow(filterResult)) {
122122 root.filterResult = filterResult
123123 included.add(root.key)
124124 return true
125125 }
@@ -158,14 +158,10 @@
158158 }
159159 }
160160 }
161161
162- function shouldShow (filterResult, {onlySubscribedChannels}) {
163- if (filterResult && onlySubscribedChannels && filterResult.hasChannel) {
164- return filterResult.matchesChannel || filterResult.matchingTags.length || filterResult.mentionsYou || filterResult.isYours
165- } else {
166- return !!filterResult
167- }
162+ function shouldShow (filterResult) {
163+ return !!filterResult
168164 }
169165
170166 function getThruCache (key, cb) {
171167 if (cache.has(key)) {

Built with git-ssb-web