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";
|
import { useUser } from "@/hooks/store";
|
||||||
|
|
||||||
const HomePage = observer(() => {
|
const HomePage = observer(() => {
|
||||||
const { data: currentUser, isAuthenticated, isLoading } = useUser();
|
const { data: currentUser, isAuthenticated, isInitializing } = useUser();
|
||||||
|
|
||||||
|
if (isInitializing)
|
||||||
if (isLoading)
|
|
||||||
return (
|
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 />
|
<LogoSpinner />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type TUserErrorStatus = {
|
|||||||
export interface IUserStore {
|
export interface IUserStore {
|
||||||
// observables
|
// observables
|
||||||
isAuthenticated: boolean;
|
isAuthenticated: boolean;
|
||||||
isLoading: boolean;
|
isInitializing: boolean;
|
||||||
error: TUserErrorStatus | undefined;
|
error: TUserErrorStatus | undefined;
|
||||||
data: IUser | undefined;
|
data: IUser | undefined;
|
||||||
// store observables
|
// store observables
|
||||||
@@ -35,7 +35,7 @@ export interface IUserStore {
|
|||||||
export class UserStore implements IUserStore {
|
export class UserStore implements IUserStore {
|
||||||
// observables
|
// observables
|
||||||
isAuthenticated: boolean = false;
|
isAuthenticated: boolean = false;
|
||||||
isLoading: boolean = true;
|
isInitializing: boolean = true;
|
||||||
error: TUserErrorStatus | undefined = undefined;
|
error: TUserErrorStatus | undefined = undefined;
|
||||||
data: IUser | undefined = undefined;
|
data: IUser | undefined = undefined;
|
||||||
// store observables
|
// store observables
|
||||||
@@ -52,7 +52,7 @@ export class UserStore implements IUserStore {
|
|||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
// observables
|
// observables
|
||||||
isAuthenticated: observable.ref,
|
isAuthenticated: observable.ref,
|
||||||
isLoading: observable.ref,
|
isInitializing: observable.ref,
|
||||||
error: observable,
|
error: observable,
|
||||||
// model observables
|
// model observables
|
||||||
data: observable,
|
data: observable,
|
||||||
@@ -87,7 +87,7 @@ export class UserStore implements IUserStore {
|
|||||||
fetchCurrentUser = async (): Promise<IUser> => {
|
fetchCurrentUser = async (): Promise<IUser> => {
|
||||||
try {
|
try {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
if (this.data === undefined) this.isLoading = true;
|
if (this.data === undefined && !this.error) this.isInitializing = true;
|
||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
});
|
});
|
||||||
const user = await this.userService.me();
|
const user = await this.userService.me();
|
||||||
@@ -95,19 +95,19 @@ export class UserStore implements IUserStore {
|
|||||||
await this.profile.fetchUserProfile();
|
await this.profile.fetchUserProfile();
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.data = user;
|
this.data = user;
|
||||||
this.isLoading = false;
|
this.isInitializing = false;
|
||||||
this.isAuthenticated = true;
|
this.isAuthenticated = true;
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.data = user;
|
this.data = user;
|
||||||
this.isLoading = false;
|
this.isInitializing = false;
|
||||||
this.isAuthenticated = false;
|
this.isAuthenticated = false;
|
||||||
});
|
});
|
||||||
return user;
|
return user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.isLoading = false;
|
this.isInitializing = false;
|
||||||
this.isAuthenticated = false;
|
this.isAuthenticated = false;
|
||||||
this.error = {
|
this.error = {
|
||||||
status: "user-fetch-error",
|
status: "user-fetch-error",
|
||||||
@@ -166,7 +166,7 @@ export class UserStore implements IUserStore {
|
|||||||
reset = (): void => {
|
reset = (): void => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.isAuthenticated = false;
|
this.isAuthenticated = false;
|
||||||
this.isLoading = false;
|
this.isInitializing = false;
|
||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
this.data = undefined;
|
this.data = undefined;
|
||||||
this.profile = new ProfileStore(this.store);
|
this.profile = new ProfileStore(this.store);
|
||||||
|
|||||||
Reference in New Issue
Block a user