You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Fix settings resetting on refresh
Don't clear localstorage when replacing the client: we clear it when logging out so this is just redundant, and since we now use replaceClient to unpickle a session from localstorage, this was blowing away all our setting on every refresh. Also Move all of the localstorage code to Lifecycle (except device ID but this will probably be generated on the server soon anyway). We previously cleared localstorage on logout in Lifecycle so persist the session in Lifecycle.setLoggedIn() to be symmetrical.
This commit is contained in:
@@ -97,32 +97,7 @@ class MatrixClientPeg {
|
||||
}
|
||||
|
||||
_replaceClient(hs_url, is_url, user_id, access_token, isGuest) {
|
||||
if (localStorage) {
|
||||
try {
|
||||
localStorage.clear();
|
||||
} catch (e) {
|
||||
console.warn("Error clearing local storage", e);
|
||||
}
|
||||
}
|
||||
this._createClient(hs_url, is_url, user_id, access_token, isGuest);
|
||||
|
||||
if (localStorage) {
|
||||
try {
|
||||
localStorage.setItem("mx_hs_url", hs_url);
|
||||
localStorage.setItem("mx_is_url", is_url);
|
||||
|
||||
if (user_id !== undefined && access_token !== undefined) {
|
||||
localStorage.setItem("mx_user_id", user_id);
|
||||
localStorage.setItem("mx_access_token", access_token);
|
||||
localStorage.setItem("mx_is_guest", JSON.stringify(isGuest));
|
||||
console.log("Session persisted for %s", user_id);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Error using local storage: can't persist session!", e);
|
||||
}
|
||||
} else {
|
||||
console.warn("No local storage available: can't persist session!");
|
||||
}
|
||||
}
|
||||
|
||||
getCredentials(): MatrixClientCreds {
|
||||
|
||||
Reference in New Issue
Block a user