diff --git a/src/hooks/useUserOperation.ts b/src/hooks/useUserOperation.ts index a8653168..a151d11f 100644 --- a/src/hooks/useUserOperation.ts +++ b/src/hooks/useUserOperation.ts @@ -131,23 +131,23 @@ const useUserOperation = ({ uid, cid }: IProps) => { updateContactStatus({ target_uid: uid, action: "unblock" }); }; - const isAdmin = !!loginUser?.is_admin; + const loginUserIsAdmin = !!loginUser?.is_admin; const loginUid = loginUser?.uid; - const canDeleteChannel = !!cid && !channel?.is_public && isAdmin; + const canDeleteChannel = !!cid && !channel?.is_public && loginUserIsAdmin; const canRemoveFromChannel = !!cid && !channel?.is_public && - (isAdmin || channel?.owner == loginUid) && + (loginUserIsAdmin || channel?.owner == loginUid) && 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 canRemoveFromContact: boolean = loginUid != uid; const canInviteChannel = !!cid && (loginUser?.is_admin || channel?.owner == loginUser?.uid); return { - isChannelOwner: loginUser?.uid == channel?.owner || (channel?.is_public && isAdmin), - isAdmin, + isChannelOwner: loginUser?.uid == channel?.owner || (channel?.is_public && loginUserIsAdmin), + isAdmin: !!user?.is_admin, updateRole, - canUpdateRole: isAdmin && loginUid != uid && uid != 1, + canUpdateRole: loginUserIsAdmin && loginUid != uid && uid != 1, removeFromContact, canBlock, canRemoveFromContact, diff --git a/src/routes/chat/SessionList/index.tsx b/src/routes/chat/SessionList/index.tsx index c4a3449e..5a8559bc 100644 --- a/src/routes/chat/SessionList/index.tsx +++ b/src/routes/chat/SessionList/index.tsx @@ -47,10 +47,10 @@ const SessionList: FC = ({ tempSession }) => { const pinTmps = pins .map((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"); } - if ("gid" in target) { + if ("gid" in target && channelIDs.includes(target.gid as number)) { return getSessionObj((target as PinChatTargetChannel).gid, "channel"); } return null; @@ -114,7 +114,7 @@ const SessionList: FC = ({ tempSession }) => { tempSession, pins ]); - console.log("sessionsss", sessions); + console.log("sessionsss", sessions, pinSessions, pins); return (