searches for streams with topic rules

This commit is contained in:
كارل مبارك 2021-07-15 14:07:40 +02:00
parent 52c0d849d7
commit e6868249a9
2 changed files with 21 additions and 6 deletions

View file

@ -65,11 +65,14 @@ export default {
return new Promise(resolve => {
api.zulip.init().then((client) => {
this.zulipClient = client;
api.zulip.getStreams(client).then((result) => {
console.log(result.streams)
api.zulip.getStreams(client).then(async (streams) => {
for (let stream of streams) {
stream.topics = await api.zulip.getTopics(client, stream.stream_id)
}
console.log(streams)
this.$store.commit(
"setStreams",
result.streams.filter((s) => s.name.startsWith(this.pubStr))
streams.filter((s) => s.topics.find(t => t.name == 'rules'))
);
resolve()
});

View file

@ -20,7 +20,18 @@ const
client
.streams
.retrieve()
.then(result => resolve(result))
.then(result => resolve(result.streams))
.catch(error => reject(error))
})
),
getTopics = (client, stream) => ( new
Promise((resolve, reject) => {
client
.streams
.topics
.retrieve({ stream_id: stream })
.then(result => resolve(result.topics))
.catch(error => reject(error))
})
),
@ -31,8 +42,8 @@ const
.messages
.retrieve(params || {
anchor: "newest",
// num_before: 100,
// num_after: 0,
num_before: 1000,
num_after: 0,
// apply_markdown: false,
narrow: [
{ operator: "stream", operand: stream },
@ -115,6 +126,7 @@ export default {
init,
config,
getStreams,
getTopics,
getMsgs,
getAllMsgs,
listen,