fix: bugs

This commit is contained in:
Tristan Yang
2024-09-13 22:31:49 +08:00
parent ecebbca0a1
commit df993cbfee
2 changed files with 10 additions and 10 deletions
+7 -7
View File
@@ -131,23 +131,23 @@ const useUserOperation = ({ uid, cid }: IProps) => {
updateContactStatus({ target_uid: uid, action: "unblock" }); updateContactStatus({ target_uid: uid, action: "unblock" });
}; };
const isAdmin = !!loginUser?.is_admin; const loginUserIsAdmin = !!loginUser?.is_admin;
const loginUid = loginUser?.uid; const loginUid = loginUser?.uid;
const canDeleteChannel = !!cid && !channel?.is_public && isAdmin; const canDeleteChannel = !!cid && !channel?.is_public && loginUserIsAdmin;
const canRemoveFromChannel = const canRemoveFromChannel =
!!cid && !!cid &&
!channel?.is_public && !channel?.is_public &&
(isAdmin || channel?.owner == loginUid) && (loginUserIsAdmin || channel?.owner == loginUid) &&
uid != channel?.owner; uid != channel?.owner;
const canRemove: boolean = isAdmin && loginUid != uid && !cid && uid !== 1; const canRemove: boolean = loginUserIsAdmin && loginUid != uid && !cid && uid !== 1;
const canBlock: boolean = loginUid != uid; const canBlock: boolean = loginUid != uid;
const canRemoveFromContact: boolean = loginUid != uid; const canRemoveFromContact: boolean = loginUid != uid;
const canInviteChannel = !!cid && (loginUser?.is_admin || channel?.owner == loginUser?.uid); const canInviteChannel = !!cid && (loginUser?.is_admin || channel?.owner == loginUser?.uid);
return { return {
isChannelOwner: loginUser?.uid == channel?.owner || (channel?.is_public && isAdmin), isChannelOwner: loginUser?.uid == channel?.owner || (channel?.is_public && loginUserIsAdmin),
isAdmin, isAdmin: !!user?.is_admin,
updateRole, updateRole,
canUpdateRole: isAdmin && loginUid != uid && uid != 1, canUpdateRole: loginUserIsAdmin && loginUid != uid && uid != 1,
removeFromContact, removeFromContact,
canBlock, canBlock,
canRemoveFromContact, canRemoveFromContact,
+3 -3
View File
@@ -47,10 +47,10 @@ const SessionList: FC<Props> = ({ tempSession }) => {
const pinTmps = pins const pinTmps = pins
.map((p) => { .map((p) => {
const { target } = p; const { target } = p;
if ("uid" in target) { if ("uid" in target && DMs.includes(target.uid as number)) {
return getSessionObj((target as PinChatTargetUser).uid, "dm"); return getSessionObj((target as PinChatTargetUser).uid, "dm");
} }
if ("gid" in target) { if ("gid" in target && channelIDs.includes(target.gid as number)) {
return getSessionObj((target as PinChatTargetChannel).gid, "channel"); return getSessionObj((target as PinChatTargetChannel).gid, "channel");
} }
return null; return null;
@@ -114,7 +114,7 @@ const SessionList: FC<Props> = ({ tempSession }) => {
tempSession, tempSession,
pins pins
]); ]);
console.log("sessionsss", sessions); console.log("sessionsss", sessions, pinSessions, pins);
return ( return (
<div className="h-full pb-14 md:pb-0 overflow-auto"> <div className="h-full pb-14 md:pb-0 overflow-auto">