dockerize, composte, and various improvements
This commit is contained in:
@@ -1,4 +1,43 @@
|
||||
<!-- eslint-disable vue/no-multiple-template-root -->
|
||||
<script lang="ts" setup>
|
||||
import { useActiveStore } from '~/stores/activeStore';
|
||||
import { useDmStore } from '~/stores/dmStore';
|
||||
import { useEmojiPickerStore } from '~/stores/emojiPickerStore';
|
||||
import { useUserStore } from '~/stores/userStore';
|
||||
import { IChannel, SafeUser } from '~/types';
|
||||
|
||||
definePageMeta({
|
||||
middleware: 'auth'
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const emojiPickerData = storeToRefs(useEmojiPickerStore()).emojiPickerData
|
||||
|
||||
if (useDmStore().dms.find((e) => { return e.id === route.params.dmId; } ) == undefined) navigateTo('/');
|
||||
if (useActiveStore().server.channel.id !== route.params.dmId) {
|
||||
const headers = useRequestHeaders(['cookie']) as Record<string, string>;
|
||||
const dm: IChannel = await $fetch(`/api/channels/${route.params.dmId}`, { headers });
|
||||
if (!dm) throw new Error('couldnt find dm.');
|
||||
useDmStore().addDM(dm);
|
||||
if (typeof route.params.dmId !== 'string') throw new Error('route.params.dmId must be a string, but got an array presumably?');
|
||||
useActiveStore().setActiveDM(dm);
|
||||
useEmojiPickerStore().closeEmojiPicker();
|
||||
}
|
||||
const participants: SafeUser[] | undefined = useActiveStore().dm.dmParticipants;
|
||||
if (!participants) throw new Error('no one is in this dm?');
|
||||
const channel = useActiveStore().dm;
|
||||
const friend = participants.find((e) => e.id !== useUserStore().user?.id)?.username;
|
||||
useHeadSafe({
|
||||
title: `@${friend} - Blop`
|
||||
});
|
||||
|
||||
function pickedEmoji(emoji: string) {
|
||||
const { $emit } = useNuxtApp();
|
||||
$emit('pickedEmoji', emoji);
|
||||
useEmojiPickerStore().closeEmojiPicker();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<MessagePane
|
||||
:channel="channel"
|
||||
@@ -16,64 +55,4 @@
|
||||
/>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { useActiveStore } from '~/stores/activeStore';
|
||||
import { useDmStore } from '~/stores/dmStore';
|
||||
import { useEmojiPickerStore } from '~/stores/emojiPickerStore';
|
||||
import { useUserStore } from '~/stores/userStore';
|
||||
import { IChannel, IMessage, SafeUser } from '~/types';
|
||||
|
||||
definePageMeta({
|
||||
middleware: 'auth'
|
||||
});
|
||||
|
||||
export default {
|
||||
async setup() {
|
||||
const route = useRoute();
|
||||
|
||||
if (useDmStore().dms.find((e) => { return e.id === route.params.dmId; } ) == undefined) navigateTo('/');
|
||||
if (useActiveStore().server.channel.id !== route.params.dmId) {
|
||||
const headers = useRequestHeaders(['cookie']) as Record<string, string>;
|
||||
const dm: IChannel = await $fetch(`/api/channels/${route.params.dmId}`, { headers });
|
||||
|
||||
if (!dm) throw new Error('couldnt find dm.');
|
||||
useDmStore().addDM(dm);
|
||||
|
||||
if (typeof route.params.dmId !== 'string') throw new Error('route.params.dmId must be a string, but got an array presumably?');
|
||||
useActiveStore().setActiveDM(dm);
|
||||
useEmojiPickerStore().closeEmojiPicker();
|
||||
}
|
||||
|
||||
const participants: SafeUser[] | undefined = useActiveStore().dm.dmParticipants;
|
||||
|
||||
if (!participants) throw new Error('no one is in this dm?');
|
||||
|
||||
const channel = useActiveStore().dm;
|
||||
|
||||
const friend = participants.find((e) => e.id !== useUserStore().user?.id)?.username;
|
||||
|
||||
useHeadSafe({
|
||||
title: `@${friend} - Blop`
|
||||
});
|
||||
|
||||
return {
|
||||
channel,
|
||||
participants
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
emojiPickerData: storeToRefs(useEmojiPickerStore()).emojiPickerData,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
pickedEmoji(emoji: string) {
|
||||
const { $emit } = useNuxtApp();
|
||||
$emit('pickedEmoji', emoji);
|
||||
useEmojiPickerStore().closeEmojiPicker();
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</template>
|
||||
Reference in New Issue
Block a user