feat: context menus in contact list page

This commit is contained in:
zerosoul
2022-06-10 09:44:14 +08:00
parent ec9bcb3233
commit 07d72d9aeb
4 changed files with 11 additions and 2 deletions
@@ -18,8 +18,10 @@ export default function ContactContextMenu({
copyEmail, copyEmail,
canCopyEmail, canCopyEmail,
startChat, startChat,
canRemove,
canRemoveFromChannel, canRemoveFromChannel,
removeFromChannel, removeFromChannel,
removeUser,
} = useContactOperation({ } = useContactOperation({
uid, uid,
cid, cid,
@@ -56,6 +58,11 @@ export default function ContactContextMenu({
title: "Remove From Channel", title: "Remove From Channel",
handler: removeFromChannel, handler: removeFromChannel,
}, },
canRemove && {
danger: true,
title: "Remove From Server",
handler: removeUser,
},
]} ]}
/> />
} }
+2
View File
@@ -25,6 +25,8 @@ export default function ContextMenu({ items = [], hideMenu = null }) {
}`} }`}
key={title} key={title}
onClick={(evt) => { onClick={(evt) => {
evt.stopPropagation();
evt.preventDefault();
handler(evt); handler(evt);
if (hideMenu) { if (hideMenu) {
hideMenu(); hideMenu();
+1 -1
View File
@@ -69,7 +69,7 @@ export default function useContactOperation({ uid, cid }) {
const canRemoveFromChannel = const canRemoveFromChannel =
cid && !channel?.is_public && (isAdmin || channel?.owner == loginUid); cid && !channel?.is_public && (isAdmin || channel?.owner == loginUid);
const canCall = loginUid != uid; const canCall = loginUid != uid;
const canRemove = isAdmin && loginUid != uid; const canRemove = isAdmin && loginUid != uid && !cid;
return { return {
canRemove, canRemove,
removeUser: handleRemove, removeUser: handleRemove,
+1 -1
View File
@@ -33,7 +33,7 @@ export default function ContactsPage() {
{contactIds.map((uid) => { {contactIds.map((uid) => {
return ( return (
<NavLink key={uid} className="session" to={`/contacts/${uid}`}> <NavLink key={uid} className="session" to={`/contacts/${uid}`}>
<Contact uid={uid} /> <Contact uid={uid} enableContextMenu={true} />
</NavLink> </NavLink>
); );
})} })}