get members
This commit is contained in:
@@ -6,7 +6,7 @@ import Account from "./models/Account";
|
||||
const store = createStore({
|
||||
state() {
|
||||
return {
|
||||
rooms: [new Room({id:12, user: "user", roomName: "room name", mailbboxId:2})],
|
||||
rooms: [new Room({ id: 12, user: "user", roomName: "room name", mailbboxId: 2 })],
|
||||
messages: [],
|
||||
accounts: [new Account(0, "ALL")],
|
||||
activeAccount: 0,
|
||||
@@ -44,6 +44,12 @@ const store = createStore({
|
||||
});
|
||||
room.messagesFetched = true;
|
||||
},
|
||||
addAddress(state, payload) {
|
||||
// todo add if not exist
|
||||
payload.addresses.forEach((address) => {
|
||||
state.addresses.push(address);
|
||||
});
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
rooms: (state) => () => {
|
||||
@@ -83,6 +89,7 @@ const store = createStore({
|
||||
},
|
||||
fetchMessages: async (context, data) => {
|
||||
if (!data.room || data.room?.fetched == false) {
|
||||
store.dispatch("fetchAddress", { roomId: data.roomId });
|
||||
API.getMessages(data.roomId)
|
||||
.then((res) => {
|
||||
context.commit("addMessages", { messages: res.data, roomId: data.roomId });
|
||||
@@ -92,6 +99,15 @@ const store = createStore({
|
||||
});
|
||||
}
|
||||
},
|
||||
fetchRoomMembers: async (context, data) => {
|
||||
API.getMembers(data.roomId)
|
||||
.then((res) => {
|
||||
context.commit("addAddress", { addresses: res.data, roomId: data.roomId });
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user