topic adding / removing / updating nnowin real-time

This commit is contained in:
كارل مبارك 2021-07-07 17:44:30 +02:00
parent 78dce918eb
commit 268623ad2a
2 changed files with 27 additions and 6 deletions

View file

@ -117,10 +117,20 @@ export default {
break
case 'update_message':
this.$store.commit('editMessage', {
mid: event.message_id,
content: event.rendered_content
})
if (
event.message_ids.length > 1 &&
event.orig_subject
){
this.$store.commit('updateTopic', {
orig_subject: event.orig_subject,
subject: event.subject
})
} else {
this.$store.commit('editMessage', {
mid: event.message_id,
content: event.rendered_content
})
}
break
case 'reaction':

View file

@ -184,10 +184,17 @@ export default createStore({
id: mid, content: content,
}, state.currentStream)]]
state.rules = newRules
}
},
updateTopic: (state, { orig_subject, subject }) => {
const topic = state.topics.find(t => t.title == orig_subject)
if (topic) {
topic.title = subject
topic.messages.forEach(m => m.subject = subject)
}
}
},
actions: {
@ -195,7 +202,11 @@ export default createStore({
getters: {
rules: state => state.rules,
sortedTopics: state => [...state.topics].sort((a, b) => a.title.localeCompare(b.title))
sortedTopics: state => (
[...state.topics]
.sort((a, b) => a.title.localeCompare(b.title))
.filter(t => t.messages.length > 0)
)
}
})