diff --git a/front/src/App.vue b/front/src/App.vue index 7cc8958..584249b 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -76,23 +76,22 @@ export default { getStreams() { return new Promise(resolve => { - api.zulip.init().then((client) => { + api.zulip.init().then(async client => { this.zulipClient = client; - api.zulip.getStreams(client).then(streams => { - for (const stream of streams) { - stream.slug = stream.name.replaceAll(' ', '_') - } - this.$store.commit( - "setStreams", - streams.filter((s) => ( - s.name.startsWith(this.pubStr) || - s.description.includes('_PUB_') - )) - ); - resolve() - }); + const streams = await api.zulip.getStreams(client) + for (const stream of streams) { + stream.slug = stream.name.replaceAll(' ', '_') + } + this.$store.commit( + "setStreams", + streams.filter((s) => ( + s.name.startsWith(this.pubStr) || + s.description.includes('_PUB_') + )) + ); api.zulip.listen(this.zulipClient, this.eventHandler); - }); + resolve() + }); }) }, diff --git a/front/src/api/zulip/index.js b/front/src/api/zulip/index.js index 3369e59..e2d8e6e 100644 --- a/front/src/api/zulip/index.js +++ b/front/src/api/zulip/index.js @@ -25,6 +25,16 @@ const }) ), + getUsers = client => ( new + Promise((resolve, reject) => { + client + .users + .retrieve() + .then(result => resolve(result.members)) + .catch(error => reject(error)) + }) + ), + getTopics = (client, stream) => ( new Promise((resolve, reject) => { client @@ -126,6 +136,7 @@ export default { init, config, getStreams, + getUsers, getTopics, getMsgs, getAllMsgs, diff --git a/front/src/components/Content/Message.vue b/front/src/components/Content/Message.vue index 376b7b2..78000ea 100644 --- a/front/src/components/Content/Message.vue +++ b/front/src/components/Content/Message.vue @@ -81,6 +81,7 @@ export default { // return emojiConv.replace_colons(":" + r.emoji_name + ":"); // }); // return []; + // console.log(this.message) return this.message.reactions.map((r) => emojiConv.replace_colons(":" + r.emoji_name + ":") ); diff --git a/front/src/components/Content/index.vue b/front/src/components/Content/index.vue index d6af106..a45ade0 100644 --- a/front/src/components/Content/index.vue +++ b/front/src/components/Content/index.vue @@ -6,7 +6,6 @@ :source="description" v-bind="$mdOpts" > - - +

+ + {{ author }} + . + and + , + +

s.name == this.currentStream.name) + }, + title() { + return this.foundStream ? this.currentStream.name : this.$route.path == '/' ? "<= pick a stream" @@ -52,9 +66,22 @@ export default { }, description() { return this.title && - this.streams.find((s) => s.name == this.currentStream.name) - .description.replace('_PUB_', '') + this.foundStream && + this.foundStream.description.replace('_PUB_', '') }, + authors() { + return [ + ...new Set( + this.title && + this.foundStream && + this.sortedTopics + .map(t => t.messages) + .flat() + .map(m => m.sender_full_name) + ), + ...[ 'Pub Bot' ] + ] + } }, methods: { toValidID(string) { @@ -67,18 +94,18 @@ export default { behavior: "smooth", }); }, + isLast: (item, array) => ( + array.indexOf(item) === array.length - 1 + ), + isBeforeLast: (item, array) => ( + array.indexOf(item) === array.length - 2 + ), }, }; \ No newline at end of file