From 6b84fcd84d9e94df4079b5815a2e16a8a2784aed Mon Sep 17 00:00:00 2001 From: Nicolas Demonte Date: Tue, 7 Apr 2020 16:40:54 +0200 Subject: [PATCH] Fix race condition #32781 --- src/pfwbged/collection/pfwbcollection.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pfwbged/collection/pfwbcollection.js b/src/pfwbged/collection/pfwbcollection.js index a7c0836..bf3bc30 100644 --- a/src/pfwbged/collection/pfwbcollection.js +++ b/src/pfwbged/collection/pfwbcollection.js @@ -533,13 +533,23 @@ function select_metatype(elem) $('div.close', window.parent.document).click(); }); - var history_state = history.state; - if (history_state !== null) { - if (history_state.metatype !== undefined) { - var metatype = $('.metatypes [value="' + history_state.metatype + '"]'); - metatype.prop('checked', true); - metatype.trigger('change'); + /* search restoration starts here */ + + var restore_ppfwbged_search = function() { + var history_state = history.state; + if (history_state !== null) { + if (history_state.metatype !== undefined) { + var metatype = $('.metatypes [value="' + history_state.metatype + '"]'); + metatype.prop('checked', true).trigger('change'); + } } - } + }; + + var waitForQuerywidget = setInterval(function () { + if ($.querywidget.initialized_over === true) { + restore_ppfwbged_search(); + clearInterval(waitForQuerywidget); + } + }, 500); }(jQuery));