From e6868249a982063551dacd3d3e8e46bd42e41da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=83=D8=A7=D8=B1=D9=84=20=D9=85=D8=A8=D8=A7=D8=B1=D9=83?= Date: Thu, 15 Jul 2021 14:07:40 +0200 Subject: [PATCH] searches for streams with topic rules --- front/src/App.vue | 9 ++++++--- front/src/api/zulip/index.js | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/front/src/App.vue b/front/src/App.vue index d69e5c4..1a6cf94 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -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() }); diff --git a/front/src/api/zulip/index.js b/front/src/api/zulip/index.js index 1c90a08..3369e59 100644 --- a/front/src/api/zulip/index.js +++ b/front/src/api/zulip/index.js @@ -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,