minor changes

This commit is contained in:
grimhilt 2023-04-14 18:37:01 +02:00
parent b48c834d36
commit 5b62fce48a
7 changed files with 12 additions and 6 deletions

View File

@ -128,7 +128,7 @@ export async function getMessages(roomId: number) {
return await execQueryAsync(query, values); return await execQueryAsync(query, values);
} }
export async function getMembers(roomId) { export async function getMembers(roomId: number) {
const query = ` const query = `
SELECT SELECT
address.address_id AS id, address.address_id AS id,

View File

@ -120,7 +120,7 @@ async function saveFromParsedData(parsed: ParsedMail, messageId: number) {
}); });
}); });
} else if (key == "attachments") { } else if (key == "attachments") {
// todo // todo attachments
} else if (["date", "messageId", "headers", "headerLines"].includes(key)) { } else if (["date", "messageId", "headers", "headerLines"].includes(key)) {
// messageId and date are already saved // messageId and date are already saved
// other field are not important and can be retrieved in source // other field are not important and can be retrieved in source

View File

@ -146,6 +146,7 @@ describe("saveMessage", () => {
await register.save(); await register.save();
// the owner of the room will be the recipient (not us)
expect(createOrRegisterOnExistence).toHaveBeenCalledWith(db.users[1].id, RoomType.DM); expect(createOrRegisterOnExistence).toHaveBeenCalledWith(db.users[1].id, RoomType.DM);
}); });
it("should create a GROUP when there is a new first message from us to multiple recipients", async () => { it("should create a GROUP when there is a new first message from us to multiple recipients", async () => {

View File

@ -29,7 +29,7 @@ export default class saveMessageDatabase {
this.rooms = []; this.rooms = [];
this.messages = []; this.messages = [];
this.room_message = []; this.room_message = [];
this.users = generateUsers(5); // todo this.users = _users;
this.roomId = 0; this.roomId = 0;
} }

View File

@ -31,7 +31,7 @@ watch(
.main { .main {
min-width: 700px; min-width: 700px;
} }
/* todo */ /* todo define size automatically */
.content { .content {
width: 700px; width: 700px;
height: 700px; height: 700px;

View File

@ -14,7 +14,6 @@ interface RoomFromBack {
userId: number; userId: number;
notSeen: number; notSeen: number;
parent_id?: number; parent_id?: number;
// todo thread
} }
interface AccountFromBack { interface AccountFromBack {
@ -99,7 +98,7 @@ const store = createStore<State>({
setActiveRoom(state, payload) { setActiveRoom(state, payload) {
state.activeRoom = payload; state.activeRoom = payload;
// todo load room on load page // todo load room on load page
const room = state.rooms.find((room) => room.id == payload); const room = roomOnId(state, payload);
if (!room) return; if (!room) return;
let roomMessage = msgOnRoomId(state, payload); let roomMessage = msgOnRoomId(state, payload);
if (!roomMessage) { if (!roomMessage) {
@ -201,6 +200,12 @@ const store = createStore<State>({
store.dispatch("fetchMessages", { roomId: roomId, obj: msgOnRoomId(state, roomId) }); store.dispatch("fetchMessages", { roomId: roomId, obj: msgOnRoomId(state, roomId) });
return msgOnRoomId(state, roomId)?.messages ?? []; return msgOnRoomId(state, roomId)?.messages ?? [];
}, },
accountOfRoom:
(state) =>
(roomId: number): string | undefined => {
const room = roomOnId(state, roomId);
return state.accounts.find((account) => account.id == room?.mailboxId)?.email;
},
}, },
actions: { actions: {
fetchAccounts: async (context) => { fetchAccounts: async (context) => {