fix(web): close connection failed alert on successful request (#6657)

This commit is contained in:
Hendrik Luup
2024-03-04 05:00:44 +02:00
committed by GitHub
parent dc1dc5b6b0
commit 250f43ae68

View File

@@ -23,8 +23,8 @@ export const RPC = {
export class Remote { export class Remote {
// TODO: decouple from controller // TODO: decouple from controller
constructor(controller) { constructor(controller) {
this._connection_alert = null;
this._controller = controller; this._controller = controller;
this._error = '';
this._session_id = ''; this._session_id = '';
} }
@@ -56,6 +56,8 @@ export class Remote {
if (callback) { if (callback) {
callback.call(context, payload, response_argument); callback.call(context, payload, response_argument);
} }
this._connection_alert = null;
}) })
.catch((error) => { .catch((error) => {
if (error.message === Remote._SessionHeader) { if (error.message === Remote._SessionHeader) {
@@ -66,13 +68,15 @@ export class Remote {
} }
console.trace(error); console.trace(error);
this._controller.togglePeriodicSessionRefresh(false); this._controller.togglePeriodicSessionRefresh(false);
this._controller.setCurrentPopup(
new AlertDialog({ this._connection_alert = new AlertDialog({
heading: 'Connection failed', heading: 'Connection failed',
message: message:
'Could not connect to the server. You may need to reload the page to reconnect.', 'Could not connect to the server. You may need to reload the page to reconnect.',
}), });
); })
.finally(() => {
this._controller.setCurrentPopup(this._connection_alert);
}); });
} }