From 819613d191df8a4c1d5b7fc760a6531de6dc7ad4 Mon Sep 17 00:00:00 2001 From: Alexandros Sigalas Date: Sat, 7 Dec 2024 10:51:04 +0200 Subject: [PATCH] Fixed error message when calling Clear cache and register hooks from admin menu. --- admin/js/app.ts | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/admin/js/app.ts b/admin/js/app.ts index b2e4cd66f1..d004e53b53 100644 --- a/admin/js/app.ts +++ b/admin/js/app.ts @@ -1574,17 +1574,31 @@ class AdminApp extends EgwApp */ clear_cache() { - let wait = this.egw.message(this.egw.lang('Clear cache and register hooks')+"\n"+this.egw.lang('Please wait...'),'info'); - let success = function (){ - wait.close(); - egw.message('Done'); - }; - this.egw.json('admin.admin_hooks.ajax_clear_cache', null, success).sendRequest(true, undefined, jQuery.proxy(function(_xmlhttp, _err) - { - this.egw.json('admin.admin_hooks.ajax_clear_cache&errored=1', null, success).sendRequest(true); - }, this)); + let wait = this.egw.message(this.egw.lang('Clear cache and register hooks') + "\n" + this.egw.lang('Please wait...'), 'info'); + + this.egw.request('admin.admin_hooks.ajax_clear_cache', []) + .then(() => { + // If the first request succeeds + wait.close(); + egw.message('Done'); + }) + .catch(() => { + // If the first request fails, retry with errored=1 + this.egw.request('admin.admin_hooks.ajax_clear_cache&errored=1', []) + .then(() => { + // If the fallback request succeeds + wait.close(); + egw.message('Done'); + }) + .catch(() => { + // If the fallback request also fails, handle the error + wait.close(); + egw.message(this.egw.lang('Failed to clear cache. Please try again later.'), 'error'); + }); + }); } + /** * Action handler for clear credentials action *