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) {
|
export async function getMembers(roomId) {
|
||||||
const query = `
|
const query = `
|
||||||
SELECT
|
SELECT
|
||||||
address.address_id AS id,
|
address.address_id,
|
||||||
address.address_name AS name,
|
address.address_name,
|
||||||
address.email AS email
|
address.email
|
||||||
FROM app_room_member
|
FROM app_room_member
|
||||||
INNER JOIN address ON address.address_id = app_room_member.member_id
|
INNER JOIN address ON address.address_id = app_room_member.member_id
|
||||||
WHERE app_room_member.room_id = ?
|
WHERE app_room_member.room_id = ?
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export function removeDuplicates(array: []) {
|
export function removeDuplicates(array: []) {
|
||||||
const unique = [];
|
let unique = [];
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
if (!unique.includes(array[i])) {
|
if (!unique.includes(array[i])) {
|
||||||
unique.push(array[i]);
|
unique.push(array[i]);
|
||||||
|
@ -30,7 +30,5 @@ export interface Account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Address {
|
export interface Address {
|
||||||
id: number;
|
todo: boolean;
|
||||||
name: string | null;
|
|
||||||
email: string;
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import API from "@/services/imapAPI";
|
import API from "@/services/imapAPI";
|
||||||
import { decodeEmojis } from "@/utils/string";
|
import { decodeEmojis } from "@/utils/string";
|
||||||
import { AxiosError, AxiosResponse } from "axios";
|
|
||||||
import { createStore, Store } from "vuex";
|
import { createStore, Store } from "vuex";
|
||||||
import { Room, Account, Address, RoomType, Message } from "./models/model";
|
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);
|
const room = state.rooms.find((room) => room.id == roomId);
|
||||||
return room;
|
return room;
|
||||||
},
|
},
|
||||||
address:
|
|
||||||
(state) =>
|
|
||||||
(addressId: number): Address | undefined => {
|
|
||||||
const address = state.addresses.find((address) => address.id == addressId);
|
|
||||||
return address;
|
|
||||||
},
|
|
||||||
messages:
|
messages:
|
||||||
(state) =>
|
(state) =>
|
||||||
(roomId: number): Message[] => {
|
(roomId: number): Message[] => {
|
||||||
@ -124,21 +117,21 @@ const store = createStore<State>({
|
|||||||
actions: {
|
actions: {
|
||||||
fetchAccounts: async (context) => {
|
fetchAccounts: async (context) => {
|
||||||
API.getAccounts()
|
API.getAccounts()
|
||||||
.then((res: AxiosResponse) => {
|
.then((res) => {
|
||||||
context.commit("addAccounts", res.data);
|
context.commit("addAccounts", res.data);
|
||||||
})
|
})
|
||||||
.catch((err: AxiosError) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fetchRooms: async (context, data) => {
|
fetchRooms: async (context, data) => {
|
||||||
if (data.account?.fetched == false) {
|
if (data.account?.fetched == false) {
|
||||||
API.getRooms(data.accountId)
|
API.getRooms(data.accountId)
|
||||||
.then((res: AxiosResponse) => {
|
.then((res) => {
|
||||||
data.account.fetched = true;
|
data.account.fetched = true;
|
||||||
context.commit("addRooms", { rooms: res.data });
|
context.commit("addRooms", { rooms: res.data });
|
||||||
})
|
})
|
||||||
.catch((err: AxiosError) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -147,20 +140,20 @@ const store = createStore<State>({
|
|||||||
if (!data.room || data.room?.fetched == false) {
|
if (!data.room || data.room?.fetched == false) {
|
||||||
store.dispatch("fetchRoomMembers", { roomId: data.roomId });
|
store.dispatch("fetchRoomMembers", { roomId: data.roomId });
|
||||||
API.getMessages(data.roomId)
|
API.getMessages(data.roomId)
|
||||||
.then((res: AxiosResponse) => {
|
.then((res) => {
|
||||||
context.commit("addMessages", { messages: res.data, roomId: data.roomId });
|
context.commit("addMessages", { messages: res.data, roomId: data.roomId });
|
||||||
})
|
})
|
||||||
.catch((err: AxiosError) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fetchRoomMembers: async (context, data) => {
|
fetchRoomMembers: async (context, data) => {
|
||||||
API.getMembers(data.roomId)
|
API.getMembers(data.roomId)
|
||||||
.then((res: AxiosResponse) => {
|
.then((res) => {
|
||||||
context.commit("addAddress", { addresses: res.data, roomId: data.roomId });
|
context.commit("addAddress", { addresses: res.data, roomId: data.roomId });
|
||||||
})
|
})
|
||||||
.catch((err: AxiosError) => {
|
.catch((err) => {
|
||||||
console.log(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>
|
<script setup>
|
||||||
import { defineProps, onMounted, ref } from "vue";
|
import { defineProps, onMounted, ref } from "vue";
|
||||||
import { decodeEmojis } from "../../utils/string";
|
import { decodeEmojis } from "../../utils/string";
|
||||||
import { removeDuplicates } from "../../utils/array";
|
|
||||||
import DOMPurify from "dompurify";
|
import DOMPurify from "dompurify";
|
||||||
import store from "@/store/store";
|
|
||||||
|
|
||||||
const props = defineProps({ data: Object });
|
const props = defineProps({ data: Object });
|
||||||
const date = new Date(props.data.date);
|
const date = new Date(props.data.date);
|
||||||
@ -32,17 +30,6 @@ onMounted(() => {
|
|||||||
`);
|
`);
|
||||||
doc.close();
|
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>
|
</script>
|
||||||
<!-- to if to is more than me
|
<!-- to if to is more than me
|
||||||
cc -->
|
cc -->
|
||||||
@ -52,9 +39,7 @@ const displayAddresses = (addressesId) => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="message">
|
<div class="message">
|
||||||
<div id="context">
|
<div id="context">
|
||||||
<div class="left" id="profile">
|
<div class="left" id="profile">{{ props.data.fromA }}</div>
|
||||||
{{ displayAddresses(props.data.fromA?.split(",")) }} - {{ props.data.fromA }}
|
|
||||||
</div>
|
|
||||||
<div class="middle">{{ decodeEmojis(props.data.subject) }}</div>
|
<div class="middle">{{ decodeEmojis(props.data.subject) }}</div>
|
||||||
<div class="right" id="date">
|
<div class="right" id="date">
|
||||||
{{
|
{{
|
||||||
|
@ -14,12 +14,31 @@
|
|||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"types": ["webpack-env", "jest"],
|
"types": [
|
||||||
|
"webpack-env",
|
||||||
|
"jest"
|
||||||
|
],
|
||||||
"paths": {
|
"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"],
|
"include": [
|
||||||
"exclude": ["node_modules"]
|
"src/**/*.ts",
|
||||||
}
|
"src/**/*.tsx",
|
||||||
|
"src/**/*.vue",
|
||||||
|
"tests/**/*.ts",
|
||||||
|
"tests/**/*.tsx"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user