mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-02-15 19:55:50 +00:00
clear state when logging out
This commit is contained in:
parent
1130628302
commit
8ecc646afa
@ -818,6 +818,7 @@ function App() {
|
|||||||
chrome.runtime.sendMessage({ action: "logout" }, (response) => {
|
chrome.runtime.sendMessage({ action: "logout" }, (response) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
resetAllStates();
|
resetAllStates();
|
||||||
|
executeEvent("logout-event", {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@ -864,6 +865,8 @@ function App() {
|
|||||||
setHasLocalNode(false);
|
setHasLocalNode(false);
|
||||||
setOpenAdvancedSettings(false);
|
setOpenAdvancedSettings(false);
|
||||||
setConfirmUseOfLocal(false)
|
setConfirmUseOfLocal(false)
|
||||||
|
setTxList([])
|
||||||
|
setMemberGroups([])
|
||||||
};
|
};
|
||||||
|
|
||||||
const authenticateWallet = async () => {
|
const authenticateWallet = async () => {
|
||||||
|
@ -909,6 +909,66 @@ export const Group = ({
|
|||||||
unsubscribeFromEvent("openDirectMessage", openDirectChatFromNotification);
|
unsubscribeFromEvent("openDirectMessage", openDirectChatFromNotification);
|
||||||
};
|
};
|
||||||
}, [directs, selectedDirect]);
|
}, [directs, selectedDirect]);
|
||||||
|
|
||||||
|
const resetAllStatesAndRefs = () => {
|
||||||
|
// Reset all useState values to their initial states
|
||||||
|
setSecretKey(null);
|
||||||
|
setSecretKeyPublishDate(null);
|
||||||
|
setSecretKeyDetails(null);
|
||||||
|
setNewEncryptionNotification(null);
|
||||||
|
setMemberCountFromSecretKeyData(null);
|
||||||
|
setSelectedGroup(null);
|
||||||
|
setSelectedDirect(null);
|
||||||
|
setGroups([]);
|
||||||
|
setDirects([]);
|
||||||
|
setAdmins([]);
|
||||||
|
setAdminsWithNames([]);
|
||||||
|
setMembers([]);
|
||||||
|
setGroupOwner(null);
|
||||||
|
setTriedToFetchSecretKey(false);
|
||||||
|
setOpenAddGroup(false);
|
||||||
|
setIsInitialGroups(false);
|
||||||
|
setOpenManageMembers(false);
|
||||||
|
setMemberGroups([]); // Assuming you're clearing the context here as well
|
||||||
|
setTimestampEnterData({});
|
||||||
|
setChatMode("groups");
|
||||||
|
setNewChat(false);
|
||||||
|
setOpenSnack(false);
|
||||||
|
setInfoSnack(null);
|
||||||
|
setIsLoadingNotifyAdmin(false);
|
||||||
|
setIsLoadingGroups(false);
|
||||||
|
setIsLoadingGroup(false);
|
||||||
|
setFirstSecretKeyInCreation(false);
|
||||||
|
setGroupSection("home");
|
||||||
|
setGroupAnnouncements({});
|
||||||
|
setDefaultThread(null);
|
||||||
|
|
||||||
|
// Reset all useRef values to their initial states
|
||||||
|
hasInitialized.current = false;
|
||||||
|
hasInitializedWebsocket.current = false;
|
||||||
|
lastGroupNotification.current = null;
|
||||||
|
isFocusedRef.current = true;
|
||||||
|
selectedGroupRef.current = null;
|
||||||
|
selectedDirectRef.current = null;
|
||||||
|
groupSectionRef.current = null;
|
||||||
|
checkGroupInterval.current = null;
|
||||||
|
isLoadingOpenSectionFromNotification.current = false;
|
||||||
|
setupGroupWebsocketInterval.current = null;
|
||||||
|
settimeoutForRefetchSecretKey.current = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const logoutEventFunc = ()=> {
|
||||||
|
resetAllStatesAndRefs()
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
subscribeToEvent("logout-event", logoutEventFunc);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsubscribeFromEvent("logout-event", logoutEventFunc);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
const openGroupChatFromNotification = (e) => {
|
const openGroupChatFromNotification = (e) => {
|
||||||
if (isLoadingOpenSectionFromNotification.current) return;
|
if (isLoadingOpenSectionFromNotification.current) return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user