Worked on several new features:

- ProfilePictures for users are now pulled from the backend
- added a component for chat settings (WIP)
- added a loading screen when the backend is not available
- reworked the "add chat" feature
- started to implement the general send-message functionality
This commit is contained in:
joschuatonn
2024-05-25 13:37:50 +02:00
parent 176abf58b2
commit c8d5bc5734
12 changed files with 486 additions and 86 deletions

View File

@@ -0,0 +1,28 @@
import { defineStore } from 'pinia';
import { api } from 'src/boot/axios';
import { message, ptpUser, responseModel } from 'src/models';
import Keycloak, { KeycloakInitOptions, KeycloakLoginOptions } from 'keycloak-js';
export const useMessageStore = defineStore('messageStore', {
state: () => ({
messages: [[]] as [message[]],
}),
actions: {
async sendMessage(chatId : number, senderId : string, content : string) {
await api.post("/messages/"+chatId+"/"+senderId+"/"+content).then((result) => {
this.loadMessagesByChatID(chatId);
});
},
loadMessagesByChatID(chatID : number) {
this.getAllMessagesByChatID(chatID).then((messages) => {
this.messages[chatID] = messages;
});
},
async getAllMessagesByChatID(chatID : number) {
return (await api.get("/messages/chat/"+chatID)).data;
},
},
});