mirror of
https://github.com/makeplane/plane
synced 2025-08-07 19:59:33 +00:00
[WEB-4635] fix: space auth screen re-loading issue (#7551)
* fix: prevent auth redirect on window focus * fix: space auth screen re-loading issue. --------- Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
committed by
GitHub
parent
806619d73f
commit
21c59692f9
@@ -9,12 +9,11 @@ import { AuthView } from "@/components/views";
|
||||
import { useUser } from "@/hooks/store";
|
||||
|
||||
const HomePage = observer(() => {
|
||||
const { data: currentUser, isAuthenticated, isLoading } = useUser();
|
||||
const { data: currentUser, isAuthenticated, isInitializing } = useUser();
|
||||
|
||||
|
||||
if (isLoading)
|
||||
if (isInitializing)
|
||||
return (
|
||||
<div className="flex items-center justify-center h-screen w-full">
|
||||
<div className="flex h-screen min-h-[500px] w-full justify-center items-center">
|
||||
<LogoSpinner />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ type TUserErrorStatus = {
|
||||
export interface IUserStore {
|
||||
// observables
|
||||
isAuthenticated: boolean;
|
||||
isLoading: boolean;
|
||||
isInitializing: boolean;
|
||||
error: TUserErrorStatus | undefined;
|
||||
data: IUser | undefined;
|
||||
// store observables
|
||||
@@ -35,7 +35,7 @@ export interface IUserStore {
|
||||
export class UserStore implements IUserStore {
|
||||
// observables
|
||||
isAuthenticated: boolean = false;
|
||||
isLoading: boolean = true;
|
||||
isInitializing: boolean = true;
|
||||
error: TUserErrorStatus | undefined = undefined;
|
||||
data: IUser | undefined = undefined;
|
||||
// store observables
|
||||
@@ -52,7 +52,7 @@ export class UserStore implements IUserStore {
|
||||
makeObservable(this, {
|
||||
// observables
|
||||
isAuthenticated: observable.ref,
|
||||
isLoading: observable.ref,
|
||||
isInitializing: observable.ref,
|
||||
error: observable,
|
||||
// model observables
|
||||
data: observable,
|
||||
@@ -87,7 +87,7 @@ export class UserStore implements IUserStore {
|
||||
fetchCurrentUser = async (): Promise<IUser> => {
|
||||
try {
|
||||
runInAction(() => {
|
||||
if (this.data === undefined) this.isLoading = true;
|
||||
if (this.data === undefined && !this.error) this.isInitializing = true;
|
||||
this.error = undefined;
|
||||
});
|
||||
const user = await this.userService.me();
|
||||
@@ -95,19 +95,19 @@ export class UserStore implements IUserStore {
|
||||
await this.profile.fetchUserProfile();
|
||||
runInAction(() => {
|
||||
this.data = user;
|
||||
this.isLoading = false;
|
||||
this.isInitializing = false;
|
||||
this.isAuthenticated = true;
|
||||
});
|
||||
} else
|
||||
runInAction(() => {
|
||||
this.data = user;
|
||||
this.isLoading = false;
|
||||
this.isInitializing = false;
|
||||
this.isAuthenticated = false;
|
||||
});
|
||||
return user;
|
||||
} catch (error) {
|
||||
runInAction(() => {
|
||||
this.isLoading = false;
|
||||
this.isInitializing = false;
|
||||
this.isAuthenticated = false;
|
||||
this.error = {
|
||||
status: "user-fetch-error",
|
||||
@@ -166,7 +166,7 @@ export class UserStore implements IUserStore {
|
||||
reset = (): void => {
|
||||
runInAction(() => {
|
||||
this.isAuthenticated = false;
|
||||
this.isLoading = false;
|
||||
this.isInitializing = false;
|
||||
this.error = undefined;
|
||||
this.data = undefined;
|
||||
this.profile = new ProfileStore(this.store);
|
||||
|
||||
Reference in New Issue
Block a user