fix duplication of threads on account change

This commit is contained in:
grimhilt 2023-04-14 23:04:09 +02:00
parent 79e17ad24f
commit 956bc35158
2 changed files with 3 additions and 4 deletions

View File

@ -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,

View File

@ -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,
);