From 7b7a855b13b94c12c0958086f61ec1bc61f5b99c Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 13 Jan 2021 09:08:53 -0700 Subject: [PATCH] =?UTF-8?q?*=20Etemplate:=20Avoid=20"Uncaught=20TypeError:?= =?UTF-8?q?=20Cannot=20read=20property=20=E2=80=98length=E2=80=99=20of=20u?= =?UTF-8?q?ndefined"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was happening when an app was open but not currently active and had a push update with no type. --- api/js/etemplate/et2_extension_nextmatch.js | 13 +++++++------ api/js/etemplate/et2_extension_nextmatch.ts | 16 +++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index 502a724f80..92871c596b 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -475,10 +475,6 @@ var et2_nextmatch = /** @class */ (function (_super) { // Make sure we're dealing with arrays if (typeof _row_ids == 'string' || typeof _row_ids == 'number') _row_ids = [_row_ids]; - if (!this.div.is(':visible')) // run refresh, once we become visible again - { - return this._queue_refresh(_row_ids, _type); - } // Make some changes in what we're doing based on preference var update_pref = egw.preference("lazy-update") || 'lazy'; if (_type == et2_nextmatch.UPDATE && !this.is_sorted_by_modified()) { @@ -492,6 +488,10 @@ var et2_nextmatch = /** @class */ (function (_super) { } if (typeof _type == 'undefined') _type = et2_nextmatch.EDIT; + if (!this.div.is(':visible')) // run refresh, once we become visible again + { + return this._queue_refresh(_row_ids, _type); + } if (typeof _row_ids == "undefined" || _row_ids === null) { this.applyFilters(); // Trigger an event so app code can act on it @@ -697,15 +697,16 @@ var et2_nextmatch = /** @class */ (function (_super) { // Maximum number of requests to queue. 50 chosen arbitrarily just to limit things var max_queued = 50; if (this._queued_refreshes === null) { - // Already too many, we'll refresh later + // Already too many or an EDIT came, we'll refresh everything later return; } // Cancel any existing listener var tab = jQuery(this.getInstanceManager().DOMContainer.parentNode) .off('show.et2_nextmatch') .one('show.et2_nextmatch', this._queue_refresh_callback.bind(this)); + // Edit means refresh everything, so no need to keep queueing // Too many? Forget it, we'll refresh everything. - if (this._queued_refreshes.length >= max_queued) { + if (this._queued_refreshes.length >= max_queued || _type == et2_nextmatch.EDIT || !_type) { this._queued_refreshes = null; return; } diff --git a/api/js/etemplate/et2_extension_nextmatch.ts b/api/js/etemplate/et2_extension_nextmatch.ts index e296268978..4d864e307d 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -746,11 +746,6 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 // Make sure we're dealing with arrays if (typeof _row_ids == 'string' || typeof _row_ids == 'number') _row_ids = [_row_ids]; - if (!this.div.is(':visible')) // run refresh, once we become visible again - { - return this._queue_refresh(_row_ids, _type); - } - // Make some changes in what we're doing based on preference let update_pref = egw.preference("lazy-update") || 'lazy'; if(_type == et2_nextmatch.UPDATE && !this.is_sorted_by_modified()) @@ -767,6 +762,12 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 } if (typeof _type == 'undefined') _type = et2_nextmatch.EDIT; + + if (!this.div.is(':visible')) // run refresh, once we become visible again + { + return this._queue_refresh(_row_ids, _type); + } + if (typeof _row_ids == "undefined" || _row_ids === null) { this.applyFilters(); @@ -1019,7 +1020,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 if(this._queued_refreshes === null) { - // Already too many, we'll refresh later + // Already too many or an EDIT came, we'll refresh everything later return; } @@ -1029,8 +1030,9 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 .one('show.et2_nextmatch', this._queue_refresh_callback.bind(this)); + // Edit means refresh everything, so no need to keep queueing // Too many? Forget it, we'll refresh everything. - if(this._queued_refreshes.length >= max_queued) + if(this._queued_refreshes.length >= max_queued || _type == et2_nextmatch.EDIT || !_type) { this._queued_refreshes = null; return;