Commit bfff9ddc0fc0159cb662f4168b1960ff7822dfa0
also display gatherings people you follow are attending, and better bump messages
Matt McKegg committed on 4/19/2018, 9:25:17 PMParent: 59d3d0d716da753cf2d23af1ad3fab75bfc9dc93
Files changed
locales/en.json | changed |
modules/feed/html/rollup.js | changed |
modules/gathering/sheet/edit.js | changed |
modules/page/html/render/gatherings.js | changed |
modules/page/html/render/public.js | changed |
locales/en.json | ||
---|---|---|
@@ -184,6 +184,12 @@ | ||
184 | 184 | "identified ": "identified ", |
185 | 185 | "All Posts from Your ": "All Posts from Your ", |
186 | 186 | "You have no followers": "You have no followers", |
187 | 187 | "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" | |
189 | 195 | } |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -11,9 +11,10 @@ | ||
11 | 11 | 'vote': 'liked this message', |
12 | 12 | 'post': 'replied to this message', |
13 | 13 | 'about': 'added changes', |
14 | 14 | 'mention': 'mentioned you', |
15 | - 'channel-mention': 'mentioned this channel' | |
15 | + 'channel-mention': 'mentioned this channel', | |
16 | + 'attending': 'can attend' | |
16 | 17 | } |
17 | 18 | |
18 | 19 | // bump even for first message |
19 | 20 | var rootBumpTypes = ['mention', 'channel-mention'] |
@@ -50,8 +51,9 @@ | ||
50 | 51 | return nest('feed.html.rollup', function (getStream, { |
51 | 52 | prepend, |
52 | 53 | rootFilter = returnTrue, |
53 | 54 | bumpFilter = returnTrue, |
55 | + resultFilter = returnTrue, // filter after replies have been resolved (just before append to scroll) | |
54 | 56 | compactFilter = returnFalse, |
55 | 57 | prefiltered = false, |
56 | 58 | displayFilter = returnTrue, |
57 | 59 | updateStream, // override the stream used for realtime updates |
@@ -195,8 +197,9 @@ | ||
195 | 197 | ) : pull( |
196 | 198 | pull.filter(bumpFilter), |
197 | 199 | api.feed.pull.rollup(rootFilter) |
198 | 200 | ), |
201 | + pull.filter(resultFilter), | |
199 | 202 | scroller |
200 | 203 | ) |
201 | 204 | }) |
202 | 205 | } |
modules/gathering/sheet/edit.js | ||
---|---|---|
@@ -54,9 +54,9 @@ | ||
54 | 54 | h('h2', { |
55 | 55 | style: { |
56 | 56 | 'font-weight': 'normal' |
57 | 57 | } |
58 | - }, [id ? i18n('Edit') : i18n('Create'), i18n(' Gathering')]), | |
58 | + }, [id ? i18n('Edit') : i18n('Create Gathering')]), | |
59 | 59 | h('GatheringEditor', [ |
60 | 60 | h('input.title', { |
61 | 61 | placeholder: i18n('Choose a title'), |
62 | 62 | hooks: [ValueHook(chosen.title), FocusHook()] |
modules/page/html/render/gatherings.js | ||
---|---|---|
@@ -23,9 +23,9 @@ | ||
23 | 23 | var following = api.contact.obs.following(id) |
24 | 24 | |
25 | 25 | var prepend = [ |
26 | 26 | h('PageHeading', [ |
27 | - h('h1', [h('strong', i18n('Gatherings')), i18n(' from your extended network')]), | |
27 | + h('h1', [h('strong', i18n('Gatherings'))]), | |
28 | 28 | h('div.meta', [ |
29 | 29 | h('button -add', { |
30 | 30 | 'ev-click': createGathering |
31 | 31 | }, i18n('+ Add Gathering')) |
@@ -34,19 +34,41 @@ | ||
34 | 34 | ] |
35 | 35 | |
36 | 36 | return api.feed.html.rollup(api.feed.pull.type('gathering'), { |
37 | 37 | 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' | |
42 | 44 | } |
43 | 45 | }, |
44 | - rootFilter: (msg) => msg.value.content.type === 'gathering', | |
46 | + resultFilter: (msg) => followsAuthor(following, id, msg) || followingIsAttending(following, msg), | |
45 | 47 | updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.latest({ids: [id]})) |
46 | 48 | }) |
47 | 49 | }) |
48 | 50 | |
49 | 51 | function createGathering () { |
50 | 52 | api.gathering.sheet.edit() |
51 | 53 | } |
52 | 54 | } |
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.js | ||
---|---|---|
@@ -99,16 +99,19 @@ | ||
99 | 99 | |
100 | 100 | var author = msg.value.author |
101 | 101 | |
102 | 102 | if (id === author || following().includes(author)) { |
103 | - return true | |
103 | + if (isAttendee(msg)) { | |
104 | + return 'attending' | |
105 | + } else { | |
106 | + return true | |
107 | + } | |
104 | 108 | } else if (matchesSubscribedChannel(msg)) { |
105 | 109 | return 'matches-channel' |
106 | 110 | } |
107 | 111 | } |
108 | 112 | }, |
109 | 113 | rootFilter: function (msg) { |
110 | - | |
111 | 114 | if (msg.value && msg.value.content && msg.value.content.type === 'contact') { |
112 | 115 | // don't show unfollows in the main feed, but do show follows and blocks |
113 | 116 | // we still show unfollows on a person's profile though |
114 | 117 | if (msg.value.content.following === false && !msg.value.content.blocking) return false |
@@ -330,4 +333,9 @@ | ||
330 | 333 | return msgA.value.author === msgB.value.author && msgA.value.content.contact === msgB.value.content.contact |
331 | 334 | } |
332 | 335 | } |
333 | 336 | } |
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