Compare commits
38 Commits
fd253197cc
...
569c271c6c
Author | SHA1 | Date | |
---|---|---|---|
|
569c271c6c | ||
|
833eacc91d | ||
|
6ea0d4e02e | ||
|
4b5bd9da67 | ||
|
8258581435 | ||
|
02e0e05c76 | ||
|
7ba1ee083d | ||
|
a5d325818b | ||
|
9fbf5e5cf3 | ||
|
1d761fa6df | ||
|
7f28823758 | ||
|
e2bd0bafea | ||
|
1a63b3154a | ||
|
053213eecb | ||
|
34c6a43fdc | ||
|
d39d66195a | ||
|
e0482eb511 | ||
|
94c7a7176b | ||
|
bffcdafe7a | ||
|
a9d15027aa | ||
|
d0d666f4cb | ||
|
b156c5954d | ||
|
097dd8bf21 | ||
|
cb5021750a | ||
|
7008e24941 | ||
|
0f87bdc715 | ||
|
47b8c54122 | ||
|
ace2063309 | ||
|
6b96815b93 | ||
|
520eb95d37 | ||
|
3e029a26d4 | ||
|
28b2b69dc8 | ||
|
c81042a223 | ||
|
749127ac19 | ||
|
61d7eb386c | ||
|
02e3af693a | ||
|
ac8211defd | ||
|
5f2cbd82b6 |
@ -101,9 +101,9 @@ export async function getMessages(roomId) {
|
||||
export async function getMembers(roomId) {
|
||||
const query = `
|
||||
SELECT
|
||||
address.address_id AS id,
|
||||
address.address_name AS name,
|
||||
address.email AS email
|
||||
address.address_id,
|
||||
address.address_name,
|
||||
address.email
|
||||
FROM app_room_member
|
||||
INNER JOIN address ON address.address_id = app_room_member.member_id
|
||||
WHERE app_room_member.room_id = ?
|
||||
|
@ -1,5 +1,5 @@
|
||||
export function removeDuplicates(array: []) {
|
||||
const unique = [];
|
||||
let unique = [];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!unique.includes(array[i])) {
|
||||
unique.push(array[i]);
|
||||
|
@ -30,7 +30,5 @@ export interface Account {
|
||||
}
|
||||
|
||||
export interface Address {
|
||||
id: number;
|
||||
name: string | null;
|
||||
email: string;
|
||||
todo: boolean;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import API from "@/services/imapAPI";
|
||||
import { decodeEmojis } from "@/utils/string";
|
||||
import { AxiosError, AxiosResponse } from "axios";
|
||||
import { createStore, Store } from "vuex";
|
||||
import { Room, Account, Address, RoomType, Message } from "./models/model";
|
||||
|
||||
@ -104,12 +103,6 @@ const store = createStore<State>({
|
||||
const room = state.rooms.find((room) => room.id == roomId);
|
||||
return room;
|
||||
},
|
||||
address:
|
||||
(state) =>
|
||||
(addressId: number): Address | undefined => {
|
||||
const address = state.addresses.find((address) => address.id == addressId);
|
||||
return address;
|
||||
},
|
||||
messages:
|
||||
(state) =>
|
||||
(roomId: number): Message[] => {
|
||||
@ -124,21 +117,21 @@ const store = createStore<State>({
|
||||
actions: {
|
||||
fetchAccounts: async (context) => {
|
||||
API.getAccounts()
|
||||
.then((res: AxiosResponse) => {
|
||||
.then((res) => {
|
||||
context.commit("addAccounts", res.data);
|
||||
})
|
||||
.catch((err: AxiosError) => {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
fetchRooms: async (context, data) => {
|
||||
if (data.account?.fetched == false) {
|
||||
API.getRooms(data.accountId)
|
||||
.then((res: AxiosResponse) => {
|
||||
.then((res) => {
|
||||
data.account.fetched = true;
|
||||
context.commit("addRooms", { rooms: res.data });
|
||||
})
|
||||
.catch((err: AxiosError) => {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
@ -147,20 +140,20 @@ const store = createStore<State>({
|
||||
if (!data.room || data.room?.fetched == false) {
|
||||
store.dispatch("fetchRoomMembers", { roomId: data.roomId });
|
||||
API.getMessages(data.roomId)
|
||||
.then((res: AxiosResponse) => {
|
||||
.then((res) => {
|
||||
context.commit("addMessages", { messages: res.data, roomId: data.roomId });
|
||||
})
|
||||
.catch((err: AxiosError) => {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
},
|
||||
fetchRoomMembers: async (context, data) => {
|
||||
API.getMembers(data.roomId)
|
||||
.then((res: AxiosResponse) => {
|
||||
.then((res) => {
|
||||
context.commit("addAddress", { addresses: res.data, roomId: data.roomId });
|
||||
})
|
||||
.catch((err: AxiosError) => {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
|
@ -1,9 +0,0 @@
|
||||
export function removeDuplicates(array: []) {
|
||||
const unique: [] = [];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!unique.includes(array[i])) {
|
||||
unique.push(array[i]);
|
||||
}
|
||||
}
|
||||
return unique;
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
<script setup>
|
||||
import { defineProps, onMounted, ref } from "vue";
|
||||
import { decodeEmojis } from "../../utils/string";
|
||||
import { removeDuplicates } from "../../utils/array";
|
||||
import DOMPurify from "dompurify";
|
||||
import store from "@/store/store";
|
||||
|
||||
const props = defineProps({ data: Object });
|
||||
const date = new Date(props.data.date);
|
||||
@ -32,17 +30,6 @@ onMounted(() => {
|
||||
`);
|
||||
doc.close();
|
||||
});
|
||||
|
||||
const displayAddresses = (addressesId) => {
|
||||
// todo store members in rooms ?
|
||||
addressesId = removeDuplicates(addressesId);
|
||||
let res = "";
|
||||
addressesId.forEach((addressId) => {
|
||||
const address = store.getters.address(addressId);
|
||||
if (address) res += address.email;
|
||||
});
|
||||
return res;
|
||||
};
|
||||
</script>
|
||||
<!-- to if to is more than me
|
||||
cc -->
|
||||
@ -52,9 +39,7 @@ const displayAddresses = (addressesId) => {
|
||||
<template>
|
||||
<div class="message">
|
||||
<div id="context">
|
||||
<div class="left" id="profile">
|
||||
{{ displayAddresses(props.data.fromA?.split(",")) }} - {{ props.data.fromA }}
|
||||
</div>
|
||||
<div class="left" id="profile">{{ props.data.fromA }}</div>
|
||||
<div class="middle">{{ decodeEmojis(props.data.subject) }}</div>
|
||||
<div class="right" id="date">
|
||||
{{
|
||||
|
@ -14,12 +14,31 @@
|
||||
"useDefineForClassFields": true,
|
||||
"sourceMap": true,
|
||||
"baseUrl": ".",
|
||||
"types": ["webpack-env", "jest"],
|
||||
"types": [
|
||||
"webpack-env",
|
||||
"jest"
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
"@/*": [
|
||||
"src/*",
|
||||
]
|
||||
},
|
||||
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.vue",
|
||||
"tests/**/*.ts",
|
||||
"tests/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user