fix duplication of threads on account change
This commit is contained in:
parent
79e17ad24f
commit
956bc35158
@ -27,7 +27,7 @@ export async function getAccounts() {
|
||||
return await execQueryAsync(query, values);
|
||||
}
|
||||
|
||||
export async function getRooms(mailboxId) {
|
||||
export async function getRooms(mailboxId: number) {
|
||||
const query = `
|
||||
SELECT
|
||||
room.room_id AS id,
|
||||
|
@ -21,8 +21,6 @@ interface AccountFromBack {
|
||||
email: string;
|
||||
}
|
||||
|
||||
const buffer: RoomFromBack[] = [];
|
||||
|
||||
function createRoom(options: RoomFromBack): Room {
|
||||
return {
|
||||
id: options.id,
|
||||
@ -117,6 +115,7 @@ const store = createStore<State>({
|
||||
},
|
||||
addRooms(state, payload) {
|
||||
// todo add if not exist
|
||||
const buffer: RoomFromBack[] = [];
|
||||
payload.rooms.forEach((room: RoomFromBack) => {
|
||||
if (room.roomType == RoomType.THREAD) {
|
||||
buffer.push(room);
|
||||
@ -174,7 +173,7 @@ const store = createStore<State>({
|
||||
},
|
||||
getters: {
|
||||
rooms: (state) => (): Room[] => {
|
||||
if (state.activeAccount === 0) return state.rooms;
|
||||
if (state.activeAccount === 0) return state.rooms.filter((room) => room.roomType != RoomType.THREAD);
|
||||
return state.rooms.filter(
|
||||
(room) => room.mailboxId == state.activeAccount && room.roomType != RoomType.THREAD,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user