only pop modal when purging is successful

This commit is contained in:
Red Adaya 2023-12-23 11:34:56 +08:00
parent 09c4a42557
commit 7e128c791b
2 changed files with 5 additions and 3 deletions

View File

@ -440,8 +440,7 @@ class SessionSettingsModal extends React.Component<{}, {}> {
return;
}
let prtn = GlobalCommandRunner.sessionPurge(this.sessionId);
commandRtnHandler(prtn, this.errorMessage);
GlobalModel.modalsModel.popModal();
commandRtnHandler(prtn, this.errorMessage, () => GlobalModel.modalsModel.popModal());
});
}

View File

@ -390,9 +390,12 @@ function getColorRGB(colorInput) {
return computedColorStyle;
}
function commandRtnHandler(prtn: Promise<CommandRtnType>, errorMessage: OV<string>) {
function commandRtnHandler(prtn: Promise<CommandRtnType>, errorMessage: OV<string>, onSuccess?: () => void) {
prtn.then((crtn) => {
if (crtn.success) {
if (onSuccess) {
onSuccess();
}
return;
}
mobx.action(() => {