now it checks for _PUB_ ind escription instrad of looking through topics, cleanned up logs, streaams have slugs (for rotuting and classes)
This commit is contained in:
parent
d243bfd8cd
commit
e5dbd6aaa8
5 changed files with 34 additions and 21 deletions
|
|
@ -50,11 +50,22 @@ export default {
|
|||
if (to.path !== from.path) {
|
||||
this.$store.commit("setTopics", []);
|
||||
this.$store.commit("setRules", []);
|
||||
this.$store.commit("setCurStream", to.path.replace("/", ""));
|
||||
if (this.currentStream != ""
|
||||
&& this.streams.find(s => s.name == this.currentStream)
|
||||
this.$store.commit("setCurStream", {
|
||||
name: to.path.replace('/', '').replaceAll('_', ' '),
|
||||
slug: to.path.replace('/', '').replaceAll(' ', '_')
|
||||
});
|
||||
if (
|
||||
this.currentStream.slug != ""
|
||||
&&
|
||||
this.streams.find(s =>
|
||||
s.name == this.currentStream.name &&
|
||||
s.slug == this.currentStream.slug
|
||||
)
|
||||
) {
|
||||
console.log('found stream')
|
||||
this.setUpDoc(this.currentStream);
|
||||
} else {
|
||||
console.log('stream does not exist')
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -67,15 +78,15 @@ export default {
|
|||
return new Promise(resolve => {
|
||||
api.zulip.init().then((client) => {
|
||||
this.zulipClient = client;
|
||||
api.zulip.getStreams(client).then(async (streams) => {
|
||||
for (let stream of streams) {
|
||||
stream.topics = await api.zulip.getTopics(client, stream.stream_id)
|
||||
api.zulip.getStreams(client).then(streams => {
|
||||
for (const stream of streams) {
|
||||
stream.slug = stream.name.replaceAll(' ', '_')
|
||||
}
|
||||
this.$store.commit(
|
||||
"setStreams",
|
||||
streams.filter((s) => (
|
||||
s.topics.find(t => t.name == 'rules') ||
|
||||
s.name.startsWith(this.pubStr)
|
||||
s.name.startsWith(this.pubStr) ||
|
||||
s.description.includes('_PUB_')
|
||||
))
|
||||
);
|
||||
resolve()
|
||||
|
|
@ -88,13 +99,13 @@ export default {
|
|||
setUpDoc(stream) {
|
||||
api.zulip.getSubs(this.zulipClient).then((result) => {
|
||||
if (
|
||||
!result.subscriptions.map((s) => s.name).includes(this.currentStream)
|
||||
!result.subscriptions.map((s) => s.name).includes(this.currentStream.name)
|
||||
) {
|
||||
api.zulip.addSub(this.zulipClient, this.currentStream);
|
||||
api.zulip.addSub(this.zulipClient, this.currentStream.name);
|
||||
}
|
||||
});
|
||||
|
||||
api.zulip.getAllMsgs(this.zulipClient, stream).then((result) => {
|
||||
api.zulip.getAllMsgs(this.zulipClient, stream.name).then((result) => {
|
||||
for (let m = 0; m < result.messages.length; m++) {
|
||||
const message = result.messages[m];
|
||||
if (message.subject == "rules") {
|
||||
|
|
@ -107,7 +118,7 @@ export default {
|
|||
},
|
||||
|
||||
eventHandler(event) {
|
||||
console.log(event);
|
||||
console.log('event:', event);
|
||||
switch (event.type) {
|
||||
case "message":
|
||||
switch (event.message.subject) {
|
||||
|
|
|
|||
|
|
@ -37,8 +37,10 @@ export default {
|
|||
...mapState(["currentStream", "streams"]),
|
||||
...mapGetters(["sortedTopics"]),
|
||||
title() {
|
||||
return this.streams.find((s) => s.name == this.currentStream)
|
||||
? this.currentStream.replace("pub-", "")
|
||||
return this.streams.find((s) => s.name == this.currentStream.name)
|
||||
? this.currentStream.name
|
||||
: this.$route.path == '/'
|
||||
? "<= pick a stream"
|
||||
: "Stream does not exist.";
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div :class="{ selected: selected }">
|
||||
<p class="name">
|
||||
<router-link :to="stream.name">
|
||||
<router-link :to="stream.slug">
|
||||
{{ stream.name }}
|
||||
</router-link>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ let toCSS = (message, currentStream) => {
|
|||
let className = "",
|
||||
emoji_code = "",
|
||||
rules = [],
|
||||
parentClassName = (currentStream || "").replace(" ", "-"),
|
||||
parentClassName = (currentStream && currentStream.slug || ""),
|
||||
id = message.id,
|
||||
is_codeblock = message.content.includes("<code>") || message.content.startsWith("```"),
|
||||
is_font = /<p><a href=".+?\.(ttf|otf|woff)/gm.test(message.content);
|
||||
|
||||
let type = is_codeblock ? "raw" : is_font ? "font" : "rule";
|
||||
console.log(type,message.content);
|
||||
// console.log(type, message.content);
|
||||
let regex = /\s?(?<selector>.+)\s*\n?{\n?(?<props>(.*;\n?)+)}/gm
|
||||
let results = content.matchAll(regex);
|
||||
results = Array.from(results);
|
||||
|
|
@ -121,7 +121,7 @@ const handleHTMLReply = message => {
|
|||
.replace(/<\/p>\n<\/blockquote>/gm, '')
|
||||
// .replace(/\n/gm, '')
|
||||
}
|
||||
console.table(message.responseTo)
|
||||
// console.table(message.responseTo)
|
||||
}
|
||||
|
||||
export default createStore({
|
||||
|
|
@ -131,7 +131,7 @@ export default createStore({
|
|||
state: {
|
||||
isMobile: false,
|
||||
streams: [],
|
||||
currentStream: '',
|
||||
currentStream: {},
|
||||
rules: [],
|
||||
topics: [],
|
||||
pubStr: 'pub-',
|
||||
|
|
@ -144,7 +144,7 @@ export default createStore({
|
|||
setCurStream: (state, stream) => state.currentStream = stream,
|
||||
setTopics: (state, topics) => state.topics = topics,
|
||||
addMessage: (state, message) => {
|
||||
if (message.display_recipient == state.currentStream) {
|
||||
if (message.display_recipient == state.currentStream.name) {
|
||||
if (message.content.startsWith('@_**')) {
|
||||
handleMDReply(message)
|
||||
} else if (
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ export default {
|
|||
return this.show_ui ? "ui" : "print";
|
||||
},
|
||||
currentStream() {
|
||||
return this.$store.state.currentStream.replace(" ", "-");
|
||||
return this.$store.state.currentStream.slug;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue