diff --git a/back/db/database.sql b/back/db/database.sql index a344dd8..62da8ad 100644 --- a/back/db/database.sql +++ b/back/db/database.sql @@ -121,7 +121,7 @@ CREATE TABLE app_room ( room_id INT AUTO_INCREMENT, room_name VARCHAR(255) NOT NULL, owner_id INT NOT NULL, - message_id INT NOT NULL, + message_id INT, room_type INT NOT NULL DEFAULT 0, lastUpdate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), PRIMARY KEY (room_id), diff --git a/back/db/imap/imap-db.ts b/back/db/imap/imap-db.ts index 692e8a5..c3c9a06 100644 --- a/back/db/imap/imap-db.ts +++ b/back/db/imap/imap-db.ts @@ -35,7 +35,6 @@ export async function getMailbox(mailboxId: number) { } export function updateMailbox(mailboxId: number, uidnext: number) { - console.log("updateMailbox", mailboxId, uidnext); const query = `UPDATE mailbox SET uidnext = ? WHERE mailbox_id = ?`; const values = [uidnext, mailboxId]; execQuery(query, values); diff --git a/back/mails/imap/Mailbox.ts b/back/mails/imap/Mailbox.ts index 90eed06..8bc46d0 100644 --- a/back/mails/imap/Mailbox.ts +++ b/back/mails/imap/Mailbox.ts @@ -137,7 +137,7 @@ export default class Mailbox { } catch (error) { logger.err("Failed to sync message " + error); } - logger.log(`Saved messages ${i + STEP > nbMessageToSync ? nbMessageToSync : i + STEP}/${nbMessageToSync}`); + logger.log(`Saved messages in uids ${i + STEP > nbMessageToSync ? nbMessageToSync : i + STEP}/${nbMessageToSync}`); } // if has receive new msg during last sync then start a new sync diff --git a/back/server.ts b/back/server.ts index 446061b..f9735d8 100644 --- a/back/server.ts +++ b/back/server.ts @@ -35,7 +35,7 @@ if (shouldReset) { if (table.table_name == "mailbox") return; console.log(table.table_name); execQuery("DELETE FROM " + table.table_name, []); - // execQuery("DROP TABLE " + table.table_name); + // execQuery("DROP TABLE " + table.table_name, []); }); }); } diff --git a/front/src/store/store.ts b/front/src/store/store.ts index 127195b..625324c 100644 --- a/front/src/store/store.ts +++ b/front/src/store/store.ts @@ -174,6 +174,12 @@ const store = createStore({ const msgs = msgOnRoomId(state, payload.roomId); const msgIndex = msgs?.messages.findIndex((msg) => msg.id == payload.messageId) ?? -1; if (msgs && msgIndex != -1) { + if (!isSeenFc(msgs.messages[msgIndex].flags)) { + const room = roomOnId(state, payload.roomId); + if (room) { + room.notSeen = room.notSeen - 1; + } + } msgs.messages.splice(msgIndex, 1); } }, diff --git a/front/src/views/room/RoomView.vue b/front/src/views/room/RoomView.vue index 4ffc6f2..ec00d48 100644 --- a/front/src/views/room/RoomView.vue +++ b/front/src/views/room/RoomView.vue @@ -51,6 +51,7 @@ function openMessageView(messageId) { const shouldBeCompact = (index) => { // show last three messages + // todo fix not changing three displayed when deleting if (messages.value?.length - 4 < index) return false; return true; };