added authors

This commit is contained in:
كارل مبارك 2021-07-23 22:38:35 +02:00
parent 2bb3b0d4f9
commit f0da6c6bac
4 changed files with 65 additions and 27 deletions

View file

@ -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()
});
})
},

View file

@ -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,

View file

@ -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 + ":")
);

View file

@ -6,7 +6,6 @@
:source="description"
v-bind="$mdOpts"
>
</vue3-markdown-it>
<ul class="index">
<li v-for="topic in sortedTopics" :key="topic.title">
@ -18,7 +17,18 @@
</router-link>
</li>
</ul>
<!-- <div style="float: none"><div style="page-break-after: always"></div></div> -->
<p class="authors">
<span
class="author"
v-for="author in authors"
:key="author"
>
<span>{{ author }}</span>
<span v-if="isLast(author, authors)">.</span>
<span v-else-if="isBeforeLast(author, authors)"> and </span>
<span v-else>, </span>
</span>
</p>
<Chapter
v-for="topic in sortedTopics"
:key="topic.title"
@ -43,8 +53,12 @@ export default {
computed: {
...mapState(["currentStream", "streams"]),
...mapGetters(["sortedTopics"]),
title() {
foundStream() {
return this.streams.find((s) => 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
),
},
};
</script>
<style scoped>
@media print {
.title {
/* display: none; */
}
}
.index {
.authors {
page-break-after: always;
}
</style>