Random colors are now assigned to every member of a chat at startup
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import {chat, profilePicture, responseModel} from 'src/models';
|
||||
import {chat, profilePicture, ptpUser, responseModel} from 'src/models';
|
||||
import { api } from 'src/boot/axios';
|
||||
import { useUserStore } from 'stores/user-store';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { getRandomHexColor } from 'src/utils';
|
||||
|
||||
export const useChatStore = defineStore('chatStore',{
|
||||
state:() => ({
|
||||
@@ -21,6 +22,13 @@ export const useChatStore = defineStore('chatStore',{
|
||||
},
|
||||
async loadChatsByUser() : Promise<chat[]>{
|
||||
this.chats = (await api.get("/users/chat/" + useUserStore().id)).data.response;
|
||||
|
||||
this.chats.forEach((c) => {
|
||||
c.members.forEach((member) => {
|
||||
member.nametagColor = getRandomHexColor();
|
||||
})
|
||||
})
|
||||
|
||||
this.chatsLoaded = true;
|
||||
return this.chats;
|
||||
},
|
||||
@@ -44,6 +52,7 @@ export const useChatStore = defineStore('chatStore',{
|
||||
console.log(members);
|
||||
return (await api.post("/chats/create/" + chatName + "/" + keycloakID, members)).data;
|
||||
},
|
||||
|
||||
async updateChat(chat : chat) {
|
||||
|
||||
const updatedChat : chat = {...chat};
|
||||
@@ -54,7 +63,6 @@ export const useChatStore = defineStore('chatStore',{
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return (await api.post("/chats/update", chat)).data;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user