feat: refactor the cache
This commit is contained in:
@@ -27,9 +27,9 @@ export default function ChannelChat({
|
||||
const dispatch = useDispatch();
|
||||
const { msgs, users, pendingMsgs } = useSelector((store) => {
|
||||
return {
|
||||
msgs: store.channelMsg[cid] || {},
|
||||
msgs: store.channelMessage[cid] || {},
|
||||
users: store.contacts,
|
||||
pendingMsgs: store.pendingMsg.channel[cid] || {},
|
||||
pendingMsgs: store.pendingMessage.channel[cid] || {},
|
||||
};
|
||||
});
|
||||
const handleClearUnreads = () => {
|
||||
|
||||
@@ -13,8 +13,8 @@ export default function DMChat({ uid = "", dropFiles = [] }) {
|
||||
const contacts = useSelector((store) => store.contacts);
|
||||
const { msgs, pendingMsgs } = useSelector((store) => {
|
||||
return {
|
||||
msgs: store.userMsg[uid] || {},
|
||||
pendingMsgs: store.pendingMsg.user[uid] || {},
|
||||
msgs: store.userMessage[uid] || {},
|
||||
pendingMsgs: store.pendingMessage.user[uid] || {},
|
||||
};
|
||||
});
|
||||
const [currUser, setCurrUser] = useState(null);
|
||||
@@ -31,7 +31,7 @@ export default function DMChat({ uid = "", dropFiles = [] }) {
|
||||
}, [dropFiles]);
|
||||
|
||||
if (!currUser) return null;
|
||||
console.log("user msgs", msgs);
|
||||
// console.log("user msgs", msgs);
|
||||
return (
|
||||
<Layout
|
||||
setDragFiles={setDragFiles}
|
||||
@@ -75,7 +75,7 @@ export default function DMChat({ uid = "", dropFiles = [] }) {
|
||||
})
|
||||
.map(([mid, msg]) => {
|
||||
if (!msg) return null;
|
||||
console.log("user msg", msg);
|
||||
// console.log("user msg", msg);
|
||||
const {
|
||||
from_uid,
|
||||
content,
|
||||
|
||||
@@ -20,17 +20,19 @@ import DMList from "./DMList";
|
||||
export default function ChatPage() {
|
||||
const [channelDropFiles, setChannelDropFiles] = useState([]);
|
||||
const [userDropFiles, setUserDropFiles] = useState([]);
|
||||
const { channels, UserMsgData, ChannelMsgData } = useSelector((store) => {
|
||||
return {
|
||||
channels: store.channels,
|
||||
UserMsgData: store.userMsg,
|
||||
ChannelMsgData: store.channelMsg,
|
||||
};
|
||||
});
|
||||
const { contacts, channels, UserMsgData, ChannelMsgData } = useSelector(
|
||||
(store) => {
|
||||
return {
|
||||
contacts: store.contacts,
|
||||
channels: store.channels,
|
||||
UserMsgData: store.userMessage,
|
||||
ChannelMsgData: store.channelMessage,
|
||||
};
|
||||
}
|
||||
);
|
||||
const [channelModalVisible, setChannelModalVisible] = useState(false);
|
||||
const [contactsModalVisible, setContactsModalVisible] = useState(false);
|
||||
const { channel_id, user_id } = useParams();
|
||||
const contacts = useSelector((store) => store.contacts);
|
||||
const toggleContactsModalVisible = () => {
|
||||
setContactsModalVisible((prev) => !prev);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user