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 { 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 { api } from 'src/boot/axios';
|
||||||
import { useUserStore } from 'stores/user-store';
|
import { useUserStore } from 'stores/user-store';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
import { getRandomHexColor } from 'src/utils';
|
||||||
|
|
||||||
export const useChatStore = defineStore('chatStore',{
|
export const useChatStore = defineStore('chatStore',{
|
||||||
state:() => ({
|
state:() => ({
|
||||||
@@ -21,6 +22,13 @@ export const useChatStore = defineStore('chatStore',{
|
|||||||
},
|
},
|
||||||
async loadChatsByUser() : Promise<chat[]>{
|
async loadChatsByUser() : Promise<chat[]>{
|
||||||
this.chats = (await api.get("/users/chat/" + useUserStore().id)).data.response;
|
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;
|
this.chatsLoaded = true;
|
||||||
return this.chats;
|
return this.chats;
|
||||||
},
|
},
|
||||||
@@ -44,6 +52,7 @@ export const useChatStore = defineStore('chatStore',{
|
|||||||
console.log(members);
|
console.log(members);
|
||||||
return (await api.post("/chats/create/" + chatName + "/" + keycloakID, members)).data;
|
return (await api.post("/chats/create/" + chatName + "/" + keycloakID, members)).data;
|
||||||
},
|
},
|
||||||
|
|
||||||
async updateChat(chat : chat) {
|
async updateChat(chat : chat) {
|
||||||
|
|
||||||
const updatedChat : chat = {...chat};
|
const updatedChat : chat = {...chat};
|
||||||
@@ -54,7 +63,6 @@ export const useChatStore = defineStore('chatStore',{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return (await api.post("/chats/update", chat)).data;
|
return (await api.post("/chats/update", chat)).data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user