Compare commits
39 Commits
569c271c6c
...
fd253197cc
Author | SHA1 | Date | |
---|---|---|---|
|
fd253197cc | ||
|
6b4264fccc | ||
|
4e48c5d813 | ||
|
4bff5be6c1 | ||
|
e3d8d3cf9b | ||
|
7f535f2e95 | ||
|
948ec3c7b4 | ||
|
3042ed972b | ||
|
11ab6a6a21 | ||
|
90dd16ee0d | ||
|
aced3b8914 | ||
|
68e1dfe7d8 | ||
|
a82ff9b85b | ||
|
8306543ddd | ||
|
6507d466ad | ||
|
44125fc55d | ||
|
14dd6b36f8 | ||
|
91898e25a5 | ||
|
185f051a63 | ||
|
838550b6cc | ||
|
5447557f91 | ||
|
62dd43c3d5 | ||
|
0ea7f5865b | ||
|
4d4ef54bcb | ||
|
926dc60920 | ||
|
d6f06f3ca6 | ||
|
9b3ddd291e | ||
|
d7029854b4 | ||
|
095efb5440 | ||
|
14e64c1fc3 | ||
|
95f39cf53a | ||
|
f9fbab3a21 | ||
|
aa9a69e17f | ||
|
3286a2e52b | ||
|
9046ccf137 | ||
|
29bf4bbdbd | ||
|
df69a7dbd9 | ||
|
427ffba725 | ||
|
d3893c682e |
@ -101,9 +101,9 @@ export async function getMessages(roomId) {
|
||||
export async function getMembers(roomId) {
|
||||
const query = `
|
||||
SELECT
|
||||
address.address_id,
|
||||
address.address_name,
|
||||
address.email
|
||||
address.address_id AS id,
|
||||
address.address_name AS name,
|
||||
address.email AS 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: []) {
|
||||
let unique = [];
|
||||
const unique = [];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!unique.includes(array[i])) {
|
||||
unique.push(array[i]);
|
||||
|
@ -30,5 +30,7 @@ export interface Account {
|
||||
}
|
||||
|
||||
export interface Address {
|
||||
todo: boolean;
|
||||
id: number;
|
||||
name: string | null;
|
||||
email: string;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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";
|
||||
|
||||
@ -103,6 +104,12 @@ 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[] => {
|
||||
@ -117,21 +124,21 @@ const store = createStore<State>({
|
||||
actions: {
|
||||
fetchAccounts: async (context) => {
|
||||
API.getAccounts()
|
||||
.then((res) => {
|
||||
.then((res: AxiosResponse) => {
|
||||
context.commit("addAccounts", res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError) => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
fetchRooms: async (context, data) => {
|
||||
if (data.account?.fetched == false) {
|
||||
API.getRooms(data.accountId)
|
||||
.then((res) => {
|
||||
.then((res: AxiosResponse) => {
|
||||
data.account.fetched = true;
|
||||
context.commit("addRooms", { rooms: res.data });
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
@ -140,20 +147,20 @@ const store = createStore<State>({
|
||||
if (!data.room || data.room?.fetched == false) {
|
||||
store.dispatch("fetchRoomMembers", { roomId: data.roomId });
|
||||
API.getMessages(data.roomId)
|
||||
.then((res) => {
|
||||
.then((res: AxiosResponse) => {
|
||||
context.commit("addMessages", { messages: res.data, roomId: data.roomId });
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
},
|
||||
fetchRoomMembers: async (context, data) => {
|
||||
API.getMembers(data.roomId)
|
||||
.then((res) => {
|
||||
.then((res: AxiosResponse) => {
|
||||
context.commit("addAddress", { addresses: res.data, roomId: data.roomId });
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError) => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
|
9
front/src/utils/array.ts
Normal file
9
front/src/utils/array.ts
Normal file
@ -0,0 +1,9 @@
|
||||
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,7 +1,9 @@
|
||||
<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);
|
||||
@ -30,6 +32,17 @@ 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 -->
|
||||
@ -39,7 +52,9 @@ onMounted(() => {
|
||||
<template>
|
||||
<div class="message">
|
||||
<div id="context">
|
||||
<div class="left" id="profile">{{ props.data.fromA }}</div>
|
||||
<div class="left" id="profile">
|
||||
{{ displayAddresses(props.data.fromA?.split(",")) }} - {{ props.data.fromA }}
|
||||
</div>
|
||||
<div class="middle">{{ decodeEmojis(props.data.subject) }}</div>
|
||||
<div class="right" id="date">
|
||||
{{
|
||||
|
@ -1,44 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "esnext",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"importHelpers": true,
|
||||
"allowJs": true,
|
||||
"moduleResolution": "node",
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"useDefineForClassFields": true,
|
||||
"sourceMap": true,
|
||||
"baseUrl": ".",
|
||||
"types": [
|
||||
"webpack-env",
|
||||
"jest"
|
||||
],
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*",
|
||||
]
|
||||
},
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
"target": "es5",
|
||||
"module": "esnext",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"importHelpers": true,
|
||||
"allowJs": true,
|
||||
"moduleResolution": "node",
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"useDefineForClassFields": true,
|
||||
"sourceMap": true,
|
||||
"baseUrl": ".",
|
||||
"types": ["webpack-env", "jest"],
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
},
|
||||
"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