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:
28
src/stores/message-store.ts
Normal file
28
src/stores/message-store.ts
Normal 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;
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user