feat: remember UI state

This commit is contained in:
zerosoul
2022-03-28 20:42:22 +08:00
parent f039668d4f
commit 28bc1cfbcd
7 changed files with 87 additions and 0 deletions
+4
View File
@@ -34,6 +34,10 @@ const tables = [
storeName: "server",
description: "store server data",
},
{
storeName: "ui",
description: "store UI state",
},
// {
// storeName: "message",
// description: "store message with key-val full data",
+6
View File
@@ -9,6 +9,7 @@ import { fullfillUserMsg } from "../slices/message.user";
import { fullfillChannels } from "../slices/channels";
import { fullfillContacts } from "../slices/contacts";
import { fullfillFootprint } from "../slices/footprint";
import { fullfillUI } from "../slices/ui";
const useRehydrate = () => {
const [iterated, setIterated] = useState(false);
const dispatch = useDispatch();
@@ -21,6 +22,7 @@ const useRehydrate = () => {
reactionMessage: {},
message: { replying: {} },
footprint: {},
ui: {},
server: {},
};
const tables = Object.keys(window.CACHE);
@@ -42,6 +44,9 @@ const useRehydrate = () => {
case "footprint":
rehydrateData.footprint[key] = data;
break;
case "ui":
rehydrateData.ui[key] = data;
break;
case "messageChannel":
rehydrateData.channelMessage[key] = data;
break;
@@ -73,6 +78,7 @@ const useRehydrate = () => {
dispatch(fullfillUserMsg(rehydrateData.userMessage));
dispatch(fullfillMessage(rehydrateData.message));
dispatch(fullfillFootprint(rehydrateData.footprint));
dispatch(fullfillUI(rehydrateData.ui));
dispatch(fullfillReactionMessage(rehydrateData.reactionMessage));
});