Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit b9c12d0

Browse files
committed
add Attending Gatherings view
1 parent def5991 commit b9c12d0

File tree

6 files changed

+72
-9
lines changed

6 files changed

+72
-9
lines changed

lib/depject/app/html/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports.needs = nest({
1212

1313
exports.gives = nest('app.html.search')
1414

15-
const pages = ['/public', '/private', '/mentions', '/all', '/gatherings']
15+
const pages = ['/public', '/private', '/mentions', '/all', '/gatherings', '/participating', '/attending-gatherings']
1616

1717
exports.create = function (api) {
1818
const i18n = api.intl.sync.i18n

lib/depject/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ module.exports = {
161161
search: require('./page/html/render/search.js'),
162162
settings: require('./page/html/render/settings.js'),
163163
tag: require('./page/html/render/tag.js'),
164-
'your-posts': require('./page/html/render/your-posts.js')
164+
'your-posts': require('./page/html/render/your-posts.js'),
165+
'attending-gatherings': require('./page/html/render/attending-gatherings.js')
165166
}
166167
}
167168
},
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { h, send } = require('mutant')
2+
const nest = require('depnest')
3+
4+
exports.needs = nest({
5+
'feed.html.rollup': 'first',
6+
'sbot.pull.resumeStream': 'first',
7+
'app.navigate': 'first',
8+
'sbot.pull.stream': 'first',
9+
'contact.obs.following': 'first',
10+
'intl.sync.i18n': 'first'
11+
})
12+
13+
exports.gives = nest('page.html.render')
14+
15+
exports.create = function (api) {
16+
const i18n = api.intl.sync.i18n
17+
return nest('page.html.render', function channel (path) {
18+
if (path !== '/attending-gatherings') return
19+
const prepend = [
20+
h('PageHeading', [
21+
h('h1', [h('strong', i18n('Attending Gatherings'))]),
22+
h('div.meta', [
23+
h('button', { 'ev-click': send(api.app.navigate, '/gatherings') }, 'View All Gatherings')
24+
])
25+
])
26+
]
27+
28+
const getStream = api.sbot.pull.resumeStream((sbot, opts) => {
29+
return sbot.patchwork.gatherings.roots(opts)
30+
}, { limit: 40, reverse: true, onlyAttending: true })
31+
32+
return api.feed.html.rollup(getStream, {
33+
prepend,
34+
updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.gatherings.latestAttending())
35+
})
36+
})
37+
}

lib/main-window.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ module.exports = function (config) {
229229
[i18n('All Threads'), '/participating'],
230230
[i18n('Threads Started By You'), '/your-posts']
231231
]),
232-
[i18n('Gatherings'), '/gatherings'],
232+
subMenu(i18n('Gatherings'), [
233+
[i18n('All'), '/gatherings'],
234+
[i18n('Attending'), '/attending-gatherings']
235+
]),
233236
[i18n('Tags'), `/tags/all/${encodeURIComponent(id)}`],
234237
[i18n('Extended Network'), '/all'],
235238
{ separator: true },

lib/plugins/gatherings.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ const threadSummary = require('../thread-summary')
66
const ResolveAbouts = require('../resolve-abouts')
77
const Paramap = require('pull-paramap')
88
const FilterBlocked = require('../filter-blocked')
9+
const LookupRoots = require('../lookup-roots')
10+
911
const async = require('async')
1012

1113
exports.manifest = {
1214
latest: 'source',
15+
latestAttending: 'source',
1316
roots: 'source'
1417
}
1518

@@ -23,7 +26,18 @@ exports.init = function (ssb) {
2326
pull.filter(msg => !!msg.filterResult)
2427
)
2528
},
26-
roots: function ({ reverse, limit, resume }) {
29+
latestAttending: function () {
30+
return pull(
31+
ssb.query.read({
32+
query: [{ $filter: { value: { content: { type: 'about', attendee: { link: ssb.id } } } } }]
33+
}),
34+
LookupRoots({ ssb }),
35+
ResolveAbouts({ ssb }),
36+
ApplyFilterResult({ ssb, passThroughOwn: true }),
37+
pull.filter(msg => !!msg.filterResult)
38+
)
39+
},
40+
roots: function ({ reverse, limit, resume, onlyAttending = false }) {
2741
// use resume option if specified
2842
const opts = { reverse, old: true, type: 'gathering', private: true }
2943
if (resume) {
@@ -45,7 +59,7 @@ exports.init = function (ssb) {
4559
ResolveAbouts({ ssb }),
4660

4761
// FILTER GATHERINGS BASED ON ATTENDEES AND AUTHOR (and hide if no title)
48-
ApplyFilterResult({ ssb }),
62+
ApplyFilterResult({ ssb, onlyAttending }),
4963
pull.filter(msg => !!msg.filterResult),
5064

5165
// ADD THREAD SUMMARY
@@ -77,7 +91,7 @@ function bumpFilter (msg) {
7791
}
7892
}
7993

80-
function ApplyFilterResult ({ ssb, passThroughOwn = false }) {
94+
function ApplyFilterResult ({ ssb, passThroughOwn = false, onlyAttending = false }) {
8195
return pull.asyncMap((msg, cb) => {
8296
const isYours = ssb.id === msg.value.author
8397
const recps = msg.value.content.recps
@@ -93,14 +107,19 @@ function ApplyFilterResult ({ ssb, passThroughOwn = false }) {
93107
const isRecp = Array.isArray(recps) && recps.includes(ssb.id)
94108
const hasTitle = !!msg.gathering.title
95109
const isVisible = passThrough || hasTitle
96-
if ((followingAttending.length || followingAuthor || isYours || isAttending || isRecp) && isVisible) {
110+
111+
if (onlyAttending && !isAttending && !isYours) {
112+
// only wanting events we are attending, and we are not attending so don't run filters
113+
} else if ((followingAttending.length || followingAuthor || isYours || isAttending || isRecp) && isVisible) {
97114
msg.filterResult = {
98115
followingAttending,
99116
followingAuthor,
117+
isAttending,
100118
isYours,
101119
hasTitle
102120
}
103121
}
122+
104123
cb(null, msg)
105124
})
106125
})

locales/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,8 @@
311311
"eo": "eo",
312312
"zh-TW": "zh-TW",
313313
"Blocking": "Blocking",
314-
"Automatically delete messages from blocked authors. This is irreversible and will cause problems with clients that share the database but do not support deleted messages. Enable at your own risk!": "Automatically delete messages from blocked authors. This is irreversible and will cause problems with clients that share the database but do not support deleted messages. Enable at your own risk!"
315-
}
314+
"Automatically delete messages from blocked authors. This is irreversible and will cause problems with clients that share the database but do not support deleted messages. Enable at your own risk!": "Automatically delete messages from blocked authors. This is irreversible and will cause problems with clients that share the database but do not support deleted messages. Enable at your own risk!",
315+
"All": "All",
316+
"Attending": "Attending",
317+
"Attending Gatherings": "Attending Gatherings"
318+
}

0 commit comments

Comments
 (0)