mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-06 23:45:52 -05:00
fix(auth): block render while logging in
This commit is contained in:
parent
74430b1a8f
commit
c31bcd0200
2 changed files with 5 additions and 4 deletions
|
@ -30,7 +30,6 @@ export interface ClientOperations {
|
||||||
|
|
||||||
export const AppContext = createContext<Client>(null!);
|
export const AppContext = createContext<Client>(null!);
|
||||||
export const StatusContext = createContext<ClientStatus>(null!);
|
export const StatusContext = createContext<ClientStatus>(null!);
|
||||||
export const OperationsContext = createContext<ClientOperations>(null!);
|
|
||||||
export const LogOutContext = createContext(() => {});
|
export const LogOutContext = createContext(() => {});
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -57,12 +56,12 @@ export default observer(({ children }: Props) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (state.auth.isLoggedIn()) {
|
if (state.auth.isLoggedIn()) {
|
||||||
|
setLoaded(false);
|
||||||
const client = state.config.createClient();
|
const client = state.config.createClient();
|
||||||
setClient(client);
|
setClient(client);
|
||||||
|
|
||||||
client
|
client
|
||||||
.useExistingSession(state.auth.getSession()!)
|
.useExistingSession(state.auth.getSession()!)
|
||||||
.then(() => setLoaded(true))
|
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
const error = takeError(err);
|
const error = takeError(err);
|
||||||
if (error === "Forbidden" || error === "Unauthorized") {
|
if (error === "Forbidden" || error === "Unauthorized") {
|
||||||
|
@ -72,7 +71,8 @@ export default observer(({ children }: Props) => {
|
||||||
setStatus(ClientStatus.DISCONNECTED);
|
setStatus(ClientStatus.DISCONNECTED);
|
||||||
openScreen({ id: "error", error });
|
openScreen({ id: "error", error });
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.finally(() => setLoaded(true));
|
||||||
} else {
|
} else {
|
||||||
setStatus(ClientStatus.READY);
|
setStatus(ClientStatus.READY);
|
||||||
setLoaded(true);
|
setLoaded(true);
|
||||||
|
|
|
@ -50,7 +50,7 @@ export function FormLogin() {
|
||||||
"x-session-token": session?.token,
|
"x-session-token": session?.token,
|
||||||
};
|
};
|
||||||
|
|
||||||
function login() {
|
async function login() {
|
||||||
auth.setSession(session);
|
auth.setSession(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ export function FormLogin() {
|
||||||
"GET",
|
"GET",
|
||||||
"/onboard/hello",
|
"/onboard/hello",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (onboarding) {
|
if (onboarding) {
|
||||||
openScreen({
|
openScreen({
|
||||||
id: "onboarding",
|
id: "onboarding",
|
||||||
|
|
Loading…
Reference in a new issue