fix: window reload after pm load failed (#2605)
This commit is contained in:
parent
2484c8ffb2
commit
3461c29411
@ -64,6 +64,7 @@ export class APIClient extends APIClientSDK {
|
|||||||
}
|
}
|
||||||
if (this.app.maintaining) {
|
if (this.app.maintaining) {
|
||||||
this.app.error = error?.response?.data?.error;
|
this.app.error = error?.response?.data?.error;
|
||||||
|
throw error;
|
||||||
return;
|
return;
|
||||||
} else if (this.app.error) {
|
} else if (this.app.error) {
|
||||||
this.app.error = null;
|
this.app.error = null;
|
||||||
|
@ -126,6 +126,7 @@ export class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
|
let loadFailed = false;
|
||||||
this.ws.on('message', (event) => {
|
this.ws.on('message', (event) => {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
console.log(data.payload);
|
console.log(data.payload);
|
||||||
@ -142,6 +143,10 @@ export class Application {
|
|||||||
this.maintaining = true;
|
this.maintaining = true;
|
||||||
this.error = data.payload;
|
this.error = data.payload;
|
||||||
} else {
|
} else {
|
||||||
|
console.log('loadFailed', loadFailed);
|
||||||
|
if (loadFailed) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
this.maintaining = false;
|
this.maintaining = false;
|
||||||
this.maintained = true;
|
this.maintained = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
@ -155,6 +160,7 @@ export class Application {
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
await this.pm.load();
|
await this.pm.load();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
loadFailed = true;
|
||||||
this.error = {
|
this.error = {
|
||||||
code: 'LOAD_ERROR',
|
code: 'LOAD_ERROR',
|
||||||
message: error.message,
|
message: error.message,
|
||||||
|
@ -5,9 +5,6 @@ export function useAppPluginLoad(app: Application) {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<Error | null>(null);
|
const [error, setError] = useState<Error | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
app.ws.on('message', (event) => {
|
|
||||||
console.log(event.data);
|
|
||||||
});
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
await app.load();
|
await app.load();
|
||||||
|
@ -141,6 +141,8 @@ const getProps = (app: Application) => {
|
|||||||
};
|
};
|
||||||
return { ...props, ...commands[app.error?.command?.name] };
|
return { ...props, ...commands[app.error?.command?.name] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
const AppMaintaining: FC<{ app: Application; error: Error }> = observer(({ app }) => {
|
const AppMaintaining: FC<{ app: Application; error: Error }> = observer(({ app }) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user