diff --git a/addressbook/js/app.ts b/addressbook/js/app.ts index 8c43f526b0..065fa325c7 100644 --- a/addressbook/js/app.ts +++ b/addressbook/js/app.ts @@ -327,25 +327,21 @@ class AddressbookApp extends EgwApp { return this.egw.open_link(url); } - let open = function(_title) + const title = _params.title ? Promise.resolve(_params.title) : this.egw.link_title('addressbook', contact_id, true); + title.then(_title => { - let title = _title || this.egw.link_title('addressbook', contact_id, open); - if (title) - { - this.egw.window.framework.tabLinkHandler(url, { - displayName: title, - icon: _params.icon || this.egw.link('/api/avatar.php', { - contact_id: contact_id, - etag: (new Date).valueOf()/86400|0 // cache for a day, better then no invalidation - }), - refreshCallback: function() { - etemplate2.getById("addressbook-view-"+this.appName)?.app_obj.addressbook.view_set_list(); - }, - id: contact_id + '-'+crm_list - }); - } - }.bind(this); - open(_params.title); + this.egw.window.framework.tabLinkHandler(url, { + displayName: _title, + icon: _params.icon || this.egw.link('/api/avatar.php', { + contact_id: contact_id, + etag: (new Date).valueOf()/86400|0 // cache for a day, better then no invalidation + }), + refreshCallback: function() { + etemplate2.getById("addressbook-view-"+this.appName)?.app_obj.addressbook.view_set_list(); + }, + id: contact_id + '-'+crm_list + }); + }); } } @@ -1626,4 +1622,4 @@ class AddressbookApp extends EgwApp } } -app.classes.addressbook = AddressbookApp; +app.classes.addressbook = AddressbookApp; \ No newline at end of file diff --git a/api/js/jsapi/egw_global.d.ts b/api/js/jsapi/egw_global.d.ts index e89fe58d78..97092f410e 100644 --- a/api/js/jsapi/egw_global.d.ts +++ b/api/js/jsapi/egw_global.d.ts @@ -355,14 +355,19 @@ declare interface IegwGlobal /** * Query a title of _app/_id * + * Deprecated default of returning string or null for no callback, will change in future to always return a Promise! + * * @param {string} _app * @param {string|number} _id - * @param {function} _callback optinal callback, required if for responses from the server - * @param {object} _context context for the callback + * @param {boolean|function|undefined} _callback true to always return a promise, false: just lookup title-cache or optional callback + * NOT giving either a boolean value or a callback is deprecated! + * @param {object|undefined} _context context for the callback * @param {boolean} _force_reload true load again from server, even if already cached - * @return {string|null} string with title if it exist in local cache or null if not + * @return {Promise|string|null} Promise for _callback given (function or true), string with title if it exists in local cache or null if not */ - link_title(_app : string, _id : string|number, _callback? : Function, _context? : object, _force_reload? : boolean) : string|null; + link_title(_app : string, _id : string|number, _callback? : Function|boolean, _context? : object, _force_reload? : boolean) : Promise|string|null; + link_title(_app : string, _id : string|number, _callback : true) : Promise; + link_title(_app : string, _id : string|number, _callback? : false) : string|null; /** * Callback to add all current title requests *