git ssb

10+

Matt McKegg / patchwork



Commit bfff9ddc0fc0159cb662f4168b1960ff7822dfa0

also display gatherings people you follow are attending, and better bump messages

Matt McKegg committed on 4/19/2018, 9:25:17 PM
Parent: 59d3d0d716da753cf2d23af1ad3fab75bfc9dc93

Files changed

locales/en.jsonchanged
modules/feed/html/rollup.jschanged
modules/gathering/sheet/edit.jschanged
modules/page/html/render/gatherings.jschanged
modules/page/html/render/public.jschanged
locales/en.jsonView
@@ -184,6 +184,12 @@
184184 "identified ": "identified ",
185185 "All Posts from Your ": "All Posts from Your ",
186186 "You have no followers": "You have no followers",
187187 "Nobody will be able to see your posts until you have a follower. The easiest way to get a follower is to use a pub invite as the pub will follow you back. If you have already redeemed a pub invite and you see it has not followed you back on your profile, try another pub.": "Nobody will be able to see your posts until you have a follower. The easiest way to get a follower is to use a pub invite as the pub will follow you back. If you have already redeemed a pub invite and you see it has not followed you back on your profile, try another pub.",
188- "Cannot load thread": "Cannot load thread"
188+ "Cannot load thread": "Cannot load thread",
189+ "can attend": "can attend",
190+ "Choose a title": "Choose a title",
191+ "Choose date and time": "Choose date and time",
192+ "Choose Banner Image...": "Choose Banner Image...",
193+ "Describe the gathering (if you want)": "Describe the gathering (if you want)",
194+ "Create Gathering": "Create Gathering"
189195 }
modules/feed/html/rollup.jsView
@@ -11,9 +11,10 @@
1111 'vote': 'liked this message',
1212 'post': 'replied to this message',
1313 'about': 'added changes',
1414 'mention': 'mentioned you',
15- 'channel-mention': 'mentioned this channel'
15+ 'channel-mention': 'mentioned this channel',
16+ 'attending': 'can attend'
1617 }
1718
1819 // bump even for first message
1920 var rootBumpTypes = ['mention', 'channel-mention']
@@ -50,8 +51,9 @@
5051 return nest('feed.html.rollup', function (getStream, {
5152 prepend,
5253 rootFilter = returnTrue,
5354 bumpFilter = returnTrue,
55+ resultFilter = returnTrue, // filter after replies have been resolved (just before append to scroll)
5456 compactFilter = returnFalse,
5557 prefiltered = false,
5658 displayFilter = returnTrue,
5759 updateStream, // override the stream used for realtime updates
@@ -195,8 +197,9 @@
195197 ) : pull(
196198 pull.filter(bumpFilter),
197199 api.feed.pull.rollup(rootFilter)
198200 ),
201+ pull.filter(resultFilter),
199202 scroller
200203 )
201204 })
202205 }
modules/gathering/sheet/edit.jsView
@@ -54,9 +54,9 @@
5454 h('h2', {
5555 style: {
5656 'font-weight': 'normal'
5757 }
58- }, [id ? i18n('Edit') : i18n('Create'), i18n(' Gathering')]),
58+ }, [id ? i18n('Edit') : i18n('Create Gathering')]),
5959 h('GatheringEditor', [
6060 h('input.title', {
6161 placeholder: i18n('Choose a title'),
6262 hooks: [ValueHook(chosen.title), FocusHook()]
modules/page/html/render/gatherings.jsView
@@ -23,9 +23,9 @@
2323 var following = api.contact.obs.following(id)
2424
2525 var prepend = [
2626 h('PageHeading', [
27- h('h1', [h('strong', i18n('Gatherings')), i18n(' from your extended network')]),
27+ h('h1', [h('strong', i18n('Gatherings'))]),
2828 h('div.meta', [
2929 h('button -add', {
3030 'ev-click': createGathering
3131 }, i18n('+ Add Gathering'))
@@ -34,19 +34,41 @@
3434 ]
3535
3636 return api.feed.html.rollup(api.feed.pull.type('gathering'), {
3737 prepend,
38- bumpFilter: function (msg) {
39- if (msg.value && msg.value.content && typeof msg.value.content === 'object') {
40- var author = msg.value.author
41- return id === author || following().includes(author)
38+ rootFilter: (msg) => isGathering(msg),
39+ bumpFilter: (msg) => {
40+ if (isGathering(msg)) {
41+ return true
42+ } else if (followsAuthor(following, id, msg) && isAttendee(msg)) {
43+ return 'attending'
4244 }
4345 },
44- rootFilter: (msg) => msg.value.content.type === 'gathering',
46+ resultFilter: (msg) => followsAuthor(following, id, msg) || followingIsAttending(following, msg),
4547 updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.latest({ids: [id]}))
4648 })
4749 })
4850
4951 function createGathering () {
5052 api.gathering.sheet.edit()
5153 }
5254 }
55+
56+function followsAuthor (following, yourId, msg) {
57+ var author = msg.value.author
58+ return yourId === author || following().includes(author)
59+}
60+
61+function followingIsAttending (following, msg) {
62+ if (Array.isArray(msg.replies)) {
63+ return msg.replies.some((reply) => isAttendee(reply) && following().includes(reply.value.author))
64+ }
65+}
66+
67+function isAttendee (msg) {
68+ var content = msg.value && msg.value.content
69+ return (content && content.type === 'about' && content.attendee && !content.attendee.remove)
70+}
71+
72+function isGathering (msg) {
73+ return (msg.value && msg.value.content && msg.value.content.type === 'gathering')
74+}
modules/page/html/render/public.jsView
@@ -99,16 +99,19 @@
9999
100100 var author = msg.value.author
101101
102102 if (id === author || following().includes(author)) {
103- return true
103+ if (isAttendee(msg)) {
104+ return 'attending'
105+ } else {
106+ return true
107+ }
104108 } else if (matchesSubscribedChannel(msg)) {
105109 return 'matches-channel'
106110 }
107111 }
108112 },
109113 rootFilter: function (msg) {
110-
111114 if (msg.value && msg.value.content && msg.value.content.type === 'contact') {
112115 // don't show unfollows in the main feed, but do show follows and blocks
113116 // we still show unfollows on a person's profile though
114117 if (msg.value.content.following === false && !msg.value.content.blocking) return false
@@ -330,4 +333,9 @@
330333 return msgA.value.author === msgB.value.author && msgA.value.content.contact === msgB.value.content.contact
331334 }
332335 }
333336 }
337+
338+function isAttendee (msg) {
339+ var content = msg.value && msg.value.content
340+ return (content && content.type === 'about' && content.attendee && !content.attendee.remove)
341+}

Built with git-ssb-web