fix login/logout state transition weirdness

This commit is contained in:
f0x 2023-01-17 20:40:35 +00:00
parent a1d184eac4
commit 87f28dacbf
3 changed files with 12 additions and 5 deletions

View File

@ -29,12 +29,16 @@ const { Error } = require("../error");
module.exports = function Authorization({ App }) {
const loginState = Redux.useSelector((state) => state.oauth.loginState);
const { isLoading, isSuccess, data: account, error } = query.useVerifyCredentialsQuery();
const [hasStoredLogin] = React.useState(loginState != "none" && loginState != "logout");
const { isLoading, isSuccess, data: account, error } = query.useVerifyCredentialsQuery(undefined, {
skip: loginState == "none" || loginState == "logout"
});
let showLogin = true;
let content = null;
if (isLoading && loginState != "none") {
if (isLoading && hasStoredLogin) {
showLogin = false;
let loadingInfo;
@ -51,7 +55,10 @@ module.exports = function Authorization({ App }) {
);
} else if (error != undefined) {
content = (
<Error error={error} />
<div>
<Error error={error} />
You can attempt logging in again below:
</div>
);
}

View File

@ -62,7 +62,7 @@ const endpoints = (build) => ({
if (app == undefined || app.client_id == undefined) {
throw {
message: "No stored registration data, can't finish login flow. Please try again:"
message: "No stored registration data, can't finish login flow."
};
}

View File

@ -42,7 +42,7 @@ module.exports = createSlice({
remove: (state, { _payload }) => {
delete state.token;
delete state.registration;
state.loginState = "none";
state.loginState = "logout";
}
}
});