refactor: useSelector

This commit is contained in:
Tristan Yang
2023-08-29 11:33:23 +08:00
parent 647bae7116
commit fe10a1c374
116 changed files with 572 additions and 661 deletions
+3 -3
View File
@@ -1,10 +1,10 @@
import { useLazyLeaveChannelQuery, useUpdateChannelMutation } from "@/app/services/channel";
import { useAppSelector } from "@/app/store";
import { shallowEqual } from "react-redux";
export default function useLeaveChannel(cid: number) {
const { channel, loginUid } = useAppSelector((store) => {
return { channel: store.channels.byId[cid], loginUid: store.authData.user?.uid };
});
const loginUid = useAppSelector((store) => store.authData.user?.uid, shallowEqual);
const channel = useAppSelector((store) => store.channels.byId[cid], shallowEqual);
const [update, { isLoading: transferring, isSuccess: transferSuccess }] =
useUpdateChannelMutation();
const [leave, { isLoading: leaving, isSuccess: leaveSuccess }] = useLazyLeaveChannelQuery();