Fix loadMemberChat
This commit is contained in:
parent
51d84c01dd
commit
a16c42acac
@ -397,6 +397,7 @@ class ChatElement extends HTMLElement {
|
|||||||
|
|
||||||
const service = await Services.getInstance();
|
const service = await Services.getInstance();
|
||||||
const members = await service.getAllMembers();
|
const members = await service.getAllMembers();
|
||||||
|
console.log("MEMBERS: ", members);
|
||||||
|
|
||||||
const memberList = document.createElement('div');
|
const memberList = document.createElement('div');
|
||||||
memberList.className = 'member-list active';
|
memberList.className = 'member-list active';
|
||||||
@ -434,8 +435,9 @@ class ChatElement extends HTMLElement {
|
|||||||
// Filter processes for the children of current process
|
// Filter processes for the children of current process
|
||||||
const service = await Services.getInstance();
|
const service = await Services.getInstance();
|
||||||
const processes = await service.getProcesses();
|
const processes = await service.getProcesses();
|
||||||
|
const memberAddresses = await service.getAddressesForMemberId(this.selectedMember);
|
||||||
|
|
||||||
const recipientAddresses = service.getAddressesForMemberId(this.selectedMember);
|
const recipientAddresses = memberAddresses.sp_addresses;
|
||||||
for (const [processId, process] of Object.entries(processes)) {
|
for (const [processId, process] of Object.entries(processes)) {
|
||||||
const description = await service.getDescription(processId, process);
|
const description = await service.getDescription(processId, process);
|
||||||
console.log('Process description:', description);
|
console.log('Process description:', description);
|
||||||
@ -468,6 +470,7 @@ class ChatElement extends HTMLElement {
|
|||||||
|
|
||||||
// Set the selected member
|
// Set the selected member
|
||||||
this.selectedMember = pairingProcess;
|
this.selectedMember = pairingProcess;
|
||||||
|
console.log("SELECTED MEMBER: ", this.selectedMember);
|
||||||
|
|
||||||
const chatHeader = this.shadowRoot?.querySelector('#chat-header');
|
const chatHeader = this.shadowRoot?.querySelector('#chat-header');
|
||||||
const messagesContainer = this.shadowRoot?.querySelector('#messages');
|
const messagesContainer = this.shadowRoot?.querySelector('#messages');
|
||||||
@ -485,8 +488,10 @@ class ChatElement extends HTMLElement {
|
|||||||
console.log('Create a new dm process');
|
console.log('Create a new dm process');
|
||||||
// We need to create a new process
|
// We need to create a new process
|
||||||
try {
|
try {
|
||||||
|
const memberAddresses = await service.getAddressesForMemberId(this.selectedMember);
|
||||||
|
console.log("MEMBER ADDRESSES: ", memberAddresses);
|
||||||
// await service.checkConnections(otherMembers);
|
// await service.checkConnections(otherMembers);
|
||||||
const res = await service.createDmProcess(this.selectedMember);
|
const res = await service.createDmProcess(memberAddresses.sp_addresses);
|
||||||
// We catch the new process here
|
// We catch the new process here
|
||||||
const updatedProcess = res.updated_process?.current_process;
|
const updatedProcess = res.updated_process?.current_process;
|
||||||
const processId = updatedProcess?.states[0]?.commited_in;
|
const processId = updatedProcess?.states[0]?.commited_in;
|
||||||
@ -494,8 +499,8 @@ class ChatElement extends HTMLElement {
|
|||||||
await service.handleApiReturn(res);
|
await service.handleApiReturn(res);
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
// Now create a first commitment
|
// Now create a first commitment
|
||||||
console.log('Created process', processId);
|
console.log('Created a dm process', processId);
|
||||||
this.processId = ProcessId;
|
this.processId = processId;
|
||||||
const createPrdReturn = await service.createPrdUpdate(processId, stateId);
|
const createPrdReturn = await service.createPrdUpdate(processId, stateId);
|
||||||
console.log(createPrdReturn);
|
console.log(createPrdReturn);
|
||||||
await service.handleApiReturn(createPrdReturn);
|
await service.handleApiReturn(createPrdReturn);
|
||||||
@ -508,10 +513,10 @@ class ChatElement extends HTMLElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (dmProcessId === null) {
|
// while (dmProcessId === null) {
|
||||||
dmProcessId = await this.lookForDmProcess();
|
// dmProcessId = await this.lookForDmProcess();
|
||||||
await new Promise(r => setTimeout(r, 1000));
|
// await new Promise(r => setTimeout(r, 1000));
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
console.log('Found DM process', dmProcessId);
|
console.log('Found DM process', dmProcessId);
|
||||||
this.processId = dmProcessId;
|
this.processId = dmProcessId;
|
||||||
@ -568,7 +573,8 @@ class ChatElement extends HTMLElement {
|
|||||||
messageContent.className = `message ${isCurrentUser ? 'user' : ''}`;
|
messageContent.className = `message ${isCurrentUser ? 'user' : ''}`;
|
||||||
|
|
||||||
console.log("SENDER: ", message.metadata.sender);
|
console.log("SENDER: ", message.metadata.sender);
|
||||||
const pairingProcess = this.addressMap[message.metadata.sender];
|
const pairingProcess = await this.getMyProcessId();
|
||||||
|
const senderEmoji = await addressToEmoji(pairingProcess);
|
||||||
const senderEmoji = await addressToEmoji(pairingProcess);
|
const senderEmoji = await addressToEmoji(pairingProcess);
|
||||||
|
|
||||||
if (message.type === 'file') {
|
if (message.type === 'file') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user