1
0
mirror of https://github.com/flarum/core.git synced 2025-08-03 06:57:54 +02:00

fix: package manager failures not showing alerts (#3647)

* fix: close `LoadingModal` when install falied
* move error handler to catch
This commit is contained in:
Ngô Quốc Đạt
2022-09-23 20:11:36 +07:00
committed by GitHub
parent 7ce9d63ed6
commit 6e1bc2daed
4 changed files with 9 additions and 8 deletions

View File

@@ -64,7 +64,6 @@ export default class Installer extends Component<InstallerAttrs> {
body: { body: {
data: this.data(), data: this.data(),
}, },
errorHandler,
}) })
.then((response) => { .then((response) => {
if (response.processing) { if (response.processing) {
@@ -79,8 +78,10 @@ export default class Installer extends Component<InstallerAttrs> {
window.location.reload(); window.location.reload();
} }
}) })
.catch(errorHandler)
.finally(() => { .finally(() => {
app.packageManager.control.setLoading(null); app.packageManager.control.setLoading(null);
app.modal.close();
m.redraw(); m.redraw();
}); });
} }

View File

@@ -104,7 +104,6 @@ export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttr
body: { body: {
data: { dryRun }, data: { dryRun },
}, },
errorHandler,
}) })
.then((response) => { .then((response) => {
if (response?.processing) { if (response?.processing) {
@@ -114,6 +113,7 @@ export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttr
window.location.reload(); window.location.reload();
} }
}) })
.catch(errorHandler)
.catch((e: RequestError) => { .catch((e: RequestError) => {
app.modal.close(); app.modal.close();
this.updateState.status = 'failure'; this.updateState.status = 'failure';

View File

@@ -47,12 +47,12 @@ export default class WhyNotModal<CustomAttrs extends WhyNotModalAttrs = WhyNotMo
package: this.attrs.package, package: this.attrs.package,
}, },
}, },
errorHandler,
}) })
.then((response) => { .then((response) => {
this.loading = false; this.loading = false;
this.whyNot = response.data.reason; this.whyNot = response.data.reason;
m.redraw(); m.redraw();
}); })
.catch(errorHandler);
} }
} }

View File

@@ -94,7 +94,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | LastUpdateCheck>({ .request<AsyncBackendResponse | LastUpdateCheck>({
method: 'POST', method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/check-for-updates`, url: `${app.forum.attribute('apiUrl')}/package-manager/check-for-updates`,
errorHandler,
}) })
.then((response) => { .then((response) => {
if ((response as AsyncBackendResponse).processing) { if ((response as AsyncBackendResponse).processing) {
@@ -106,6 +105,7 @@ export default class ControlSectionState {
m.redraw(); m.redraw();
} }
}) })
.catch(errorHandler)
.finally(() => { .finally(() => {
this.setLoading(null); this.setLoading(null);
m.redraw(); m.redraw();
@@ -121,7 +121,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | null>({ .request<AsyncBackendResponse | null>({
method: 'POST', method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/minor-update`, url: `${app.forum.attribute('apiUrl')}/package-manager/minor-update`,
errorHandler,
}) })
.then((response) => { .then((response) => {
if (response?.processing) { if (response?.processing) {
@@ -131,6 +130,7 @@ export default class ControlSectionState {
window.location.reload(); window.location.reload();
} }
}) })
.catch(errorHandler)
.finally(() => { .finally(() => {
this.setLoading(null); this.setLoading(null);
app.modal.close(); app.modal.close();
@@ -147,7 +147,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | null>({ .request<AsyncBackendResponse | null>({
method: 'PATCH', method: 'PATCH',
url: `${app.forum.attribute('apiUrl')}/package-manager/extensions/${extension.id}`, url: `${app.forum.attribute('apiUrl')}/package-manager/extensions/${extension.id}`,
errorHandler,
}) })
.then((response) => { .then((response) => {
if (response?.processing) { if (response?.processing) {
@@ -162,6 +161,7 @@ export default class ControlSectionState {
window.location.reload(); window.location.reload();
} }
}) })
.catch(errorHandler)
.finally(() => { .finally(() => {
this.setLoading(null); this.setLoading(null);
app.modal.close(); app.modal.close();
@@ -177,7 +177,6 @@ export default class ControlSectionState {
.request<AsyncBackendResponse | null>({ .request<AsyncBackendResponse | null>({
method: 'POST', method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/global-update`, url: `${app.forum.attribute('apiUrl')}/package-manager/global-update`,
errorHandler,
}) })
.then((response) => { .then((response) => {
if (response?.processing) { if (response?.processing) {
@@ -187,6 +186,7 @@ export default class ControlSectionState {
window.location.reload(); window.location.reload();
} }
}) })
.catch(errorHandler)
.finally(() => { .finally(() => {
this.setLoading(null); this.setLoading(null);
app.modal.close(); app.modal.close();