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