Skip to content

Commit

Permalink
fix: package manager failures not showing alerts (#3647)
Browse files Browse the repository at this point in the history
* fix: close `LoadingModal` when install falied
* move error handler to catch
  • Loading branch information
datlechin committed Sep 23, 2022
1 parent bfbccb5 commit 07b7797
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion js/src/admin/components/Installer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default class Installer extends Component<InstallerAttrs> {
body: {
data: this.data(),
},
errorHandler,
})
.then((response) => {
if (response.processing) {
Expand All @@ -79,8 +78,10 @@ export default class Installer extends Component<InstallerAttrs> {
window.location.reload();
}
})
.catch(errorHandler)
.finally(() => {
app.packageManager.control.setLoading(null);
app.modal.close();
m.redraw();
});
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/admin/components/MajorUpdater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttr
body: {
data: { dryRun },
},
errorHandler,
})
.then((response) => {
if (response?.processing) {
Expand All @@ -114,6 +113,7 @@ export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttr
window.location.reload();
}
})
.catch(errorHandler)
.catch((e: RequestError) => {
app.modal.close();
this.updateState.status = 'failure';
Expand Down
4 changes: 2 additions & 2 deletions js/src/admin/components/WhyNotModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export default class WhyNotModal<CustomAttrs extends WhyNotModalAttrs = WhyNotMo
package: this.attrs.package,
},
},
errorHandler,
})
.then((response) => {
this.loading = false;
this.whyNot = response.data.reason;
m.redraw();
});
})
.catch(errorHandler);
}
}
8 changes: 4 additions & 4 deletions js/src/admin/states/ControlSectionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | LastUpdateCheck>({
method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/check-for-updates`,
errorHandler,
})
.then((response) => {
if ((response as AsyncBackendResponse).processing) {
Expand All @@ -106,6 +105,7 @@ export default class ControlSectionState {
m.redraw();
}
})
.catch(errorHandler)
.finally(() => {
this.setLoading(null);
m.redraw();
Expand All @@ -121,7 +121,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | null>({
method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/minor-update`,
errorHandler,
})
.then((response) => {
if (response?.processing) {
Expand All @@ -131,6 +130,7 @@ export default class ControlSectionState {
window.location.reload();
}
})
.catch(errorHandler)
.finally(() => {
this.setLoading(null);
app.modal.close();
Expand All @@ -147,7 +147,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | null>({
method: 'PATCH',
url: `${app.forum.attribute('apiUrl')}/package-manager/extensions/${extension.id}`,
errorHandler,
})
.then((response) => {
if (response?.processing) {
Expand All @@ -162,6 +161,7 @@ export default class ControlSectionState {
window.location.reload();
}
})
.catch(errorHandler)
.finally(() => {
this.setLoading(null);
app.modal.close();
Expand All @@ -177,7 +177,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | null>({
method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/global-update`,
errorHandler,
})
.then((response) => {
if (response?.processing) {
Expand All @@ -187,6 +186,7 @@ export default class ControlSectionState {
window.location.reload();
}
})
.catch(errorHandler)
.finally(() => {
this.setLoading(null);
app.modal.close();
Expand Down

0 comments on commit 07b7797

Please sign in to comment.