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 => { return new Promise(resolve => {
api.zulip.init().then((client) => { api.zulip.init().then((client) => {
this.zulipClient = client; this.zulipClient = client;
api.zulip.getStreams(client).then((result) => { api.zulip.getStreams(client).then(async (streams) => {
console.log(result.streams) for (let stream of streams) {
stream.topics = await api.zulip.getTopics(client, stream.stream_id)
}
console.log(streams)
this.$store.commit( this.$store.commit(
"setStreams", "setStreams",
result.streams.filter((s) => s.name.startsWith(this.pubStr)) streams.filter((s) => s.topics.find(t => t.name == 'rules'))
); );
resolve() resolve()
}); });

View file

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