feat: users online status

This commit is contained in:
zerosoul
2022-02-19 15:57:25 +08:00
parent f96ca44841
commit 656df7c670
10 changed files with 79 additions and 19 deletions
+7 -1
View File
@@ -3,6 +3,7 @@ import { useSelector, useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import { useGetContactsQuery } from "../../app/services/contact";
import { clearAuthData } from "../../app/slices/auth.data";
import { setContacts } from "../../app/slices/contacts";
// import { useGetChannelsQuery } from "../../app/services/channel";
import { useGetServerQuery } from "../../app/services/server";
@@ -41,8 +42,13 @@ export default function usePreload() {
if (!matchedUser) {
dispatch(clearAuthData());
navigate("/login");
} else {
const markedContacts = contacts.map((u) => {
return u.uid == matchedUser.uid ? { ...u, online: true } : u;
});
dispatch(setContacts(markedContacts));
setChecked(true);
}
setChecked(true);
}
}, [contacts]);