refactor: useSelector -> useAppSelector

This commit is contained in:
Tristan Yang
2022-07-21 18:37:13 +08:00
parent 275f0110d3
commit b79abcfa9f
9 changed files with 10 additions and 43 deletions
-1
View File
@@ -9,7 +9,6 @@ const Styled = styled.div`
align-items: center;
width: 100%;
padding: 30px 0;
/* background-color: #eee; */
`;
export default function LoadMore({ pullUp = null }) {
const ref = useRef(undefined);
+7 -8
View File
@@ -1,7 +1,6 @@
// import React from 'react';
import { useState } from "react";
import { useState, MouseEvent } from "react";
import { useParams } from "react-router-dom";
import { useSelector } from "react-redux";
import { AiOutlineCaretDown } from "react-icons/ai";
@@ -18,30 +17,30 @@ import ChannelList from "./ChannelList";
import UsersModal from "../../common/component/UsersModal";
import ChannelModal from "../../common/component/ChannelModal";
import DMList from "./DMList";
import { useAppSelector } from "../../app/store";
export default function ChatPage() {
const [channelDropFiles, setChannelDropFiles] = useState([]);
const [userDropFiles, setUserDropFiles] = useState([]);
const { sessionUids } = useSelector((store) => {
const { sessionUids } = useAppSelector((store) => {
return {
sessionUids: store.userMessage.ids
};
});
const [channelModalVisible, setChannelModalVisible] = useState(false);
const [usersModalVisible, setUsersModalVisible] = useState(false);
const { channel_id, user_id } = useParams();
const { channel_id, user_id = 0 } = useParams();
const toggleUsersModalVisible = () => {
setUsersModalVisible((prev) => !prev);
};
const toggleChannelModalVisible = () => {
setChannelModalVisible((prev) => !prev);
};
const handleToggleExpand = (evt) => {
const handleToggleExpand = (evt: MouseEvent<HTMLElement>) => {
const { currentTarget } = evt;
const listEle = currentTarget.parentElement.parentElement;
listEle.classList.toggle("collapse");
currentTarget.classList.toggle("collapse");
};
const tmpUid = sessionUids.findIndex((i) => i == user_id) > -1 ? null : user_id;
const tmpUid = sessionUids.findIndex((i) => i == +user_id) > -1 ? null : user_id;
// console.log("temp uid", tmpUid);
const placeholderVisible = !channel_id && !user_id;
return (