Many fix and improvements
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<div class="mx-2 content-center">
|
||||
|
||||
<img :src="profileUrl"
|
||||
<img :src="userStore.portraitUrl"
|
||||
alt="Profile Image"
|
||||
class="rounded-full"
|
||||
width="32px"
|
||||
@@ -35,10 +35,12 @@
|
||||
|
||||
<script setup>
|
||||
|
||||
import {useClient} from '@/plugins/api.js';
|
||||
import {ref} from 'vue';
|
||||
import {useUserStore} from "@/stores/user.js";
|
||||
import {v7} from 'uuid'
|
||||
import {useRouter} from "vue-router";
|
||||
import {useClient} from '@/plugins/api.js';
|
||||
import {useUserStore} from "@/stores/userStore.js";
|
||||
import {useAuthStore} from "@/stores/authStore.js";
|
||||
|
||||
const props = defineProps({
|
||||
subjectId: {
|
||||
@@ -51,13 +53,19 @@ const emit = defineEmits(['message-posted'])
|
||||
|
||||
const client = useClient()
|
||||
const value = ref("")
|
||||
const user = useUserStore()
|
||||
const profileUrl = ref(user.getCurrentUser().storedDataUrls.profilePictureUrl ?? '/images/usersmedia/anonyme/profilepictures/profileAnonymeSquare.png')
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const publish = async () => {
|
||||
|
||||
if (!authStore.isAuthenticated) {
|
||||
await router.push('/login')
|
||||
}
|
||||
|
||||
try {
|
||||
const messageId = v7()
|
||||
|
||||
await client.post(`/api/messages/`,
|
||||
{
|
||||
"id": messageId,
|
||||
@@ -65,17 +73,16 @@ const publish = async () => {
|
||||
"message": value.value
|
||||
})
|
||||
|
||||
const currentUser = user.getCurrentUser()
|
||||
emit('message-posted',
|
||||
{
|
||||
"id": messageId,
|
||||
"subjectId": props.subjectId,
|
||||
"createdBy": currentUser.id,
|
||||
"createdByName": currentUser.alias ?? `${currentUser.firstName} ${currentUser.lastName}`,
|
||||
"createdByPortraitUrl": currentUser.storedDataUrls.profilePictureUrl,
|
||||
"createdBy": userStore.user.id,
|
||||
"createdByName": userStore.alias,
|
||||
"createdByPortraitUrl": userStore.portraitUrl,
|
||||
"createdAt": new Date(Date.now()).toISOString(),
|
||||
"value": value.value,
|
||||
parentId: null,
|
||||
"parentId": null
|
||||
})
|
||||
|
||||
value.value = ''
|
||||
|
||||
Reference in New Issue
Block a user