mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Can leave / delete a conversation
This commit is contained in:
parent
506a0a7d38
commit
9dbbf0eb5f
@ -585,6 +585,36 @@ const ConvChatWindow = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Leave conversation
|
||||||
|
if(member.user_id == userID()) {
|
||||||
|
let removeLink = createElem2({
|
||||||
|
type: "a",
|
||||||
|
appendTo: status,
|
||||||
|
innerHTML: tr("Leave")
|
||||||
|
})
|
||||||
|
|
||||||
|
removeLink.addEventListener("click", async e => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const isLastAdmin = conv.members.filter(m => m.is_admin && m.user_id != userID()).length == 0;
|
||||||
|
const msg = isLastAdmin ? tr("As you are its last admin, if you leave this conversation, it will be permanently deleted!")
|
||||||
|
: tr("Do you really want to leave this conversation?");
|
||||||
|
|
||||||
|
if(!await showConfirmDialog(msg))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ConversationsInterface.leaveConversation(conv.id, member.user_id);
|
||||||
|
|
||||||
|
// Close the conversation
|
||||||
|
info.box.closeFunction();
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e);
|
||||||
|
notify(tr("Failed to leave conversation!"), "danger");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Enable slimscrooll
|
//Enable slimscrooll
|
||||||
|
@ -483,6 +483,18 @@ const ConversationsInterface = {
|
|||||||
}, true);
|
}, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave a conversation
|
||||||
|
*
|
||||||
|
* @param {number} convID Conversation ID
|
||||||
|
* @param {number} userID Target user
|
||||||
|
*/
|
||||||
|
leaveConversation: async function(convID, userID) {
|
||||||
|
await api("conversations/delete", {
|
||||||
|
conversationID: convID,
|
||||||
|
userID: userID
|
||||||
|
}, true);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty conversations cache
|
* Empty conversations cache
|
||||||
|
Loading…
Reference in New Issue
Block a user