Neutralize chat page

This commit is contained in:
NicolasCantu 2025-03-28 12:52:00 +01:00
parent 51c906866e
commit cc9396c4b8
5 changed files with 47 additions and 58 deletions

View File

@ -1,18 +1,18 @@
import { SignatureComponent } from './pages/signature/signature-component';
import { SignatureElement } from './pages/signature/signature';
import { ChatComponent } from './pages/chat/chat-component';
import { ChatElement } from './pages/chat/chat';
/*import { ChatComponent } from './pages/chat/chat-component';
import { ChatElement } from './pages/chat/chat';*/
import { AccountComponent } from './pages/account/account-component';
import { AccountElement } from './pages/account/account';
export { SignatureComponent, SignatureElement, ChatComponent, ChatElement, AccountComponent, AccountElement };
export { SignatureComponent, SignatureElement, AccountComponent, AccountElement };
declare global {
interface HTMLElementTagNameMap {
'signature-component': SignatureComponent;
'signature-element': SignatureElement;
'chat-component': ChatComponent;
'chat-element': ChatElement;
/*'chat-component': ChatComponent;
'chat-element': ChatElement;*/
'account-component': AccountComponent;
'account-element': AccountElement;
}
@ -23,8 +23,8 @@ if ((import.meta as any).env.VITE_IS_INDEPENDANT_LIB) {
// Initialiser les composants si nécessaire
customElements.define('signature-component', SignatureComponent);
customElements.define('signature-element', SignatureElement);
customElements.define('chat-component', ChatComponent);
customElements.define('chat-element', ChatElement);
/*customElements.define('chat-component', ChatComponent);
customElements.define('chat-element', ChatElement);*/
customElements.define('account-component', AccountComponent);
customElements.define('account-element', AccountElement);
}

View File

@ -1,4 +1,4 @@
import { ChatElement } from './chat';
/*import { ChatElement } from './chat';
import chatCss from '../../../public/style/chat.css?raw';
import Services from '../../services/service.js';
@ -46,4 +46,4 @@ class ChatComponent extends HTMLElement {
}
export { ChatComponent };
customElements.define('chat-component', ChatComponent);
customElements.define('chat-component', ChatComponent);*/

View File

@ -1,3 +1,4 @@
<!--
<!DOCTYPE html>
<html lang="en">

View File

@ -1,4 +1,4 @@
declare global {
/*declare global {
interface Window {
loadMemberChat: (memberId: string | number) => void;
}
@ -385,37 +385,38 @@ class ChatElement extends HTMLElement {
}
}
private async lookForChildren(): Promise<string | null> {
// Filter processes for the children of current process
const service = await Services.getInstance();
if (!this.selectedChatProcessId) {
console.error('No process id');
return null;
}
const children: string[] = await service.getChildrenOfProcess(this.selectedChatProcessId);
// TODO rewrite that
// private async lookForChildren(): Promise<string | null> {
// // Filter processes for the children of current process
// const service = await Services.getInstance();
// if (!this.selectedChatProcessId) {
// console.error('No process id');
// return null;
// }
// const children: string[] = await service.getChildrenOfProcess(this.selectedChatProcessId);
const processRoles = this.processRoles;
const selectedMember = this.selectedMember;
for (const child of children) {
const roles = service.getRoles(JSON.parse(child));
// Check that we and the other members are in the role
if (!service.isChildRole(processRoles, roles)) {
console.error('Child process roles are not a subset of parent')
continue;
}
if (!service.rolesContainsMember(roles, selectedMember)) {
console.error('Member is not part of the process');
continue;
}
if (!service.rolesContainsUs(roles)) {
console.error('We\'re not part of child process');
continue;
}
return child;
}
// const processRoles = this.processRoles;
// const selectedMember = this.selectedMember;
// for (const child of children) {
// const roles = service.getRoles(JSON.parse(child));
// // Check that we and the other members are in the role
// if (!service.isChildRole(processRoles, roles)) {
// console.error('Child process roles are not a subset of parent')
// continue;
// }
// if (!service.rolesContainsMember(roles, selectedMember)) {
// console.error('Member is not part of the process');
// continue;
// }
// if (!service.rolesContainsUs(roles)) {
// console.error('We\'re not part of child process');
// continue;
// }
// return child;
// }
return null;
}
// return null;
// }
private async loadAllMembers() {
const groupList = this.shadowRoot?.querySelector('#group-list');
@ -689,18 +690,6 @@ class ChatElement extends HTMLElement {
this.selectedChatProcessId = dmProcessId;
}
/* TODO
console.log("Je suis messagesProcess", messagesProcess);
// --- GET THE STATE ID ---
const messagesProcessStateId = messagesProcess?.states?.[0]?.state_id;
console.log("Je suis messagesProcessStateId", messagesProcessStateId);
// --- GET THE DIFF FROM THE STATE ID ---
if (messagesProcessStateId) {
const diffFromStateId = await this.getDiffByStateId(messagesProcessStateId);
console.log("Je suis diffFromStateId", diffFromStateId);
}*/
// Récupérer les messages depuis les états du processus
const allMessages: any[] = [];
@ -1072,7 +1061,7 @@ class ChatElement extends HTMLElement {
await this.loadAllProcesses(processSet);
break;
case 'members':
await this.lookForMyDms():
await this.lookForMyDms();
await this.loadAllMembers();
break;
default:
@ -1745,6 +1734,5 @@ class ChatElement extends HTMLElement {
}
customElements.define('chat-element', ChatElement);
export { ChatElement };
export { ChatElement };*/

View File

@ -1,6 +1,6 @@
import '../public/style/4nk.css';
import { initHeader } from '../src/components/header/header';
import { initChat } from '../src/pages/chat/chat';
/*import { initChat } from '../src/pages/chat/chat';*/
import Database from './services/database.service';
import Services from './services/service';
import { cleanSubscriptions } from './utils/subscription.utils';
@ -94,7 +94,7 @@ async function handleLocation(path: string) {
}
break;
case 'chat':
/*case 'chat':
const { ChatComponent } = await import('./pages/chat/chat-component');
const chatContainer = document.querySelector('.group-list');
if (chatContainer) {
@ -104,7 +104,7 @@ async function handleLocation(path: string) {
const chatComponent = document.createElement('chat-component');
chatContainer.appendChild(chatComponent);
}
break;
break;*/
case 'signature':
const { SignatureComponent } = await import('./pages/signature/signature-component');
@ -225,7 +225,7 @@ document.addEventListener('navigate', ((e: Event) => {
const container = document.querySelector('.container');
if (container) container.innerHTML = '';
initChat();
//initChat();
const chatElement = document.querySelector('chat-element');
if (chatElement) {