From b8fa676e1612929e6a709bd14af268131df51f49 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: Fri, 2 Jul 2021 22:20:08 +0200 Subject: [PATCH] prepped for more streams, vue3 store not reactive when pushing to rules array, wonky fix --- front/src/App.vue | 64 +++++++++++---------- front/src/components/Content/index.vue | 14 ++++- front/src/components/Rules/Rule.vue | 4 +- front/src/components/Rules/Styles.vue | 35 +++++------- front/src/components/Rules/index.vue | 12 ++++ front/src/components/Streams/Stream.vue | 2 + front/src/components/Streams/index.vue | 7 ++- front/src/store/index.js | 75 ++++++++++++++++--------- 8 files changed, 131 insertions(+), 82 deletions(-) diff --git a/front/src/App.vue b/front/src/App.vue index f138ed3..7084050 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -2,7 +2,6 @@
@@ -34,7 +33,6 @@ export default { return { api: api, zulipClient: null, - stream: null, }; }, computed: { @@ -49,13 +47,11 @@ export default { this.getStreams(); this.$router.afterEach((to) => { + this.$store.commit("setContents", []); + this.$store.commit("setRules", []); this.$store.commit("setCurStream", to.path.replace("/", "")) - this.stream = to.path.replace("/", "") - if (this.stream != "") { - this.setUpDoc(this.stream); - } else { - this.$store.commit("setContents", []); - this.$store.commit("setRules", []); + if (this.currentStream != "") { + this.setUpDoc(this.currentStream); } }); }, @@ -64,29 +60,29 @@ export default { checkIfMobile: () => window.innerWidth < 700, getStreams() { - api - .zulip - .init() - .then(client => { + api.zulip.init().then(client => { this.zulipClient = client - api - .zulip - .getStreams(client) - .then(result => { - this - .$store - .commit( 'setStreams', - result - .streams - .filter(s => - s.name.startsWith(this.pubStr) - ) + api.zulip.getStreams(client).then(result => { + this.$store.commit( 'setStreams', + result.streams + .filter(s => s.name.startsWith(this.pubStr)) ) }) + api.zulip.listen(this.zulipClient, this.eventHandler) }) }, setUpDoc(stream) { + + api.zulip.getSubs(this.zulipClient).then(result => { + if ( + !result.subscriptions + .map(s => s.name) + .includes(this.currentStream) + ) { + api.zulip.addSub(this.zulipClient, this.currentStream) + } + }) api.zulip.getMsgs(this.zulipClient, stream, "content").then((result) => { for (let m = 0; m < result.messages.length; m++) { @@ -99,8 +95,6 @@ export default { this.$store.commit("setRules", result.messages); }); - api.zulip.listen(this.zulipClient, this.eventHandler) - }, eventHandler(event) { @@ -125,7 +119,7 @@ export default { case 'update_message': this.$store.commit('editMessage', { mid: event.message_id, - content: event.content + content: event.rendered_content }) break @@ -192,17 +186,27 @@ main { section { position: relative; box-sizing: border-box; - margin-left: 1em; - min-width: 500px; + /* margin-left: 1em; */ + padding: 1em; + min-width: 800px; max-width: 800px; display: flex; flex-direction: column; overflow: scroll; + background: lightgray; +} +section p { + margin-bottom: 0; + margin-top: 0; } - section .title { + display: none; font-weight: bold; position: sticky; top: 1em; } + +@media print { + .title { display: none; } +} diff --git a/front/src/components/Content/index.vue b/front/src/components/Content/index.vue index 1e732e6..7c6c985 100644 --- a/front/src/components/Content/index.vue +++ b/front/src/components/Content/index.vue @@ -1,7 +1,10 @@