reactions and a bunch of bug fixes
This commit is contained in:
@@ -13,27 +13,27 @@ definePageMeta({
|
||||
export default {
|
||||
async setup() {
|
||||
const route = useRoute()
|
||||
|
||||
const headers = useRequestHeaders(['cookie']) as Record<string, string>
|
||||
const server: IChannel = await $fetch(`/api/channels/${route.params.id}`, { headers })
|
||||
|
||||
if (!server) throw new Error('could not find the dm')
|
||||
|
||||
useGlobalStore().addDM(server);
|
||||
if (typeof route.params.id !== 'string') throw new Error('route.params.id must be a string, but got an array presumably?')
|
||||
useGlobalStore().setActive('dms', route.params.id);
|
||||
useGlobalStore().setActiveServer('dms', route.params.id);
|
||||
|
||||
function parseBody(body) {
|
||||
function parseBody(body: string) {
|
||||
const mentions = body.match(/<@([a-z]|[0-9]){25}>/g);
|
||||
|
||||
if (mentions) {
|
||||
mentions.forEach((e: string) => {
|
||||
if (!e) return
|
||||
const id = e.split('<@')[1]?.split('>')[0];
|
||||
if (!id) return;
|
||||
const user = server.dmParticipants.find((e) => e.id === id)
|
||||
const user = server.dmParticipants?.find((e) => e.id === id)
|
||||
if (!user) return;
|
||||
body = body.split(e).join(`@${user.username}`)
|
||||
});
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ export default {
|
||||
e.body = parseBody(e.body)
|
||||
})
|
||||
|
||||
useGlobalStore().setActiveChannel(server)
|
||||
|
||||
return {
|
||||
server
|
||||
}
|
||||
@@ -48,7 +50,9 @@ export default {
|
||||
async updated() {
|
||||
const route = useRoute()
|
||||
if (typeof route.params.id !== 'string') throw new Error('route.params.id must be a string, but got an array presumably?')
|
||||
if (useGlobalStore().activeServer !== this.server) useGlobalStore().setActive('dms', route.params.id)
|
||||
if (useGlobalStore().activeServer !== this.server) {
|
||||
useGlobalStore().setActiveServer('dms', route.params.id)
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
useGlobalStore().setActive('dms', '@me')
|
||||
useGlobalStore().setActiveServer('dms', '@me')
|
||||
},
|
||||
methods: {
|
||||
async startDM() {
|
||||
|
||||
Reference in New Issue
Block a user