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" });
};
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,
+3 -3
View File
@@ -47,10 +47,10 @@ const SessionList: FC<Props> = ({ 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<Props> = ({ tempSession }) => {
tempSession,
pins
]);
console.log("sessionsss", sessions);
console.log("sessionsss", sessions, pinSessions, pins);
return (
<div className="h-full pb-14 md:pb-0 overflow-auto">