From dd6c588eb5138d6d5db541d432117ec4d14541b7 Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Wed, 29 May 2024 08:44:53 +0200 Subject: [PATCH] Removed some old models and adjusted the component accordingly --- src/models.ts | 25 +++++-------------------- src/pages/IndexPage.vue | 31 ++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/models.ts b/src/models.ts index c9ddd3b..25593e8 100644 --- a/src/models.ts +++ b/src/models.ts @@ -3,17 +3,8 @@ export interface ptpUser { firstName: string; lastName: string; username: string; - status?: string; - profilePictureUrl?: string; -} - -export interface ptpTestUser { - id: string; - firstName: string; - lastName: string; - username: string; - status?: string; - profilePictureUrl?: string; + status: string; + profilepicture: string; } export interface responseModel { @@ -27,20 +18,14 @@ export interface chat{ members: ptpUser[]; messages: message[]; displayName: string; -} - -export interface user{ - id: string; - firstName: string; - lastName: string; - username: string; - chats: chat[]; + profilepicture: string; + profilepictureAsString: string; } export interface message { id: number; chat: chat; - sender:user; + sender:ptpUser; content: string; timestamp: string; isOwn: boolean; diff --git a/src/pages/IndexPage.vue b/src/pages/IndexPage.vue index 74a0b80..3ffc4b4 100644 --- a/src/pages/IndexPage.vue +++ b/src/pages/IndexPage.vue @@ -28,11 +28,11 @@
No search results found @@ -67,7 +67,7 @@ v-else :user="userStore.users.find((user) => user.id === chat.members.find((member) => member.id !== userStore.user!.id)?.id)" :selected="selectedUser.id == chat.members[0].id" - @click="selectUser(chat.members[0] as ptpTestUser)" + @click="selectUser(chat.members[0] as ptpUser)" >-->
@@ -111,7 +111,7 @@ round flat v-if="userStore.userLoaded" - :style="{'background-image' : 'url('+userStore.user!.profilePictureUrl+')' }" + :style="{'background-image' : 'url('+userStore.user!.profilepicture+')' }" style="background-size: cover;background-position: center;position: fixed; left:1rem; bottom: 1rem;" title="Profil und Einstellungen" @click="settingsDialog = true" @@ -126,13 +126,13 @@
@@ -259,8 +259,8 @@ import ProfileCardComponent from 'components/ProfileCardComponent.vue'; import ChatCardComponent from 'components/ChatCardComponent.vue'; import HeaderInfoContainerComponent from 'components/HeaderInfoContainerComponent.vue'; - import {message, ptpTestUser} from 'src/models'; - import type {chat} from 'src/models'; + import {message} from 'src/models'; + import type {chat, ptpUser} from 'src/models'; import {useUserStore} from 'stores/user-store'; import { useChatStore } from 'stores/chat-store'; import SettingsPopUp from 'src/components/SettingsPopUp.vue'; @@ -381,6 +381,15 @@ import { useMessageStore } from 'src/stores/message-store'; changed.value = true; } + function getMessages() { + if(selectedChat.value.id != null) { + messageStore.loadMessagesByChatID(selectedChat.value.id); + } + + } + + setInterval(getMessages, 2000); + setInterval(getGifs, 500); @@ -390,17 +399,17 @@ import { useMessageStore } from 'src/stores/message-store'; await chatStore.loadChatsByUser(); }; - const selectedUser = ref({} as ptpTestUser); + const selectedUser = ref({} as ptpUser); const selectedChat = ref({} as chat); - function selectUser(user : ptpTestUser) { + function selectUser(user : ptpUser) { selectedUser.value = user; selectedChat.value = {} as chat; } function selectChat(chat : chat) { selectedChat.value = chat; - selectedUser.value = {} as ptpTestUser; + selectedUser.value = {} as ptpUser; if(messageStore.messages[chat.id] == null) { messageStore.messages[chat.id] = [] as message[];