From d4b3f7844cf5bb65dd5e8b78cec249c8e1c85c02 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 14 Jul 2023 16:41:58 +0200 Subject: [PATCH] Fix sending "undefined" to sync favorites Signed-off-by: William Desportes --- js/src/functions.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/src/functions.js b/js/src/functions.js index 28c1d214a5..1654f17121 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -3806,14 +3806,22 @@ AJAX.registerOnload('functions.js', function () { // Sync favorite tables from localStorage to pmadb. if ($('#sync_favorite_tables').length) { + var favoriteTables = ''; + if (isStorageSupported('localStorage') + && typeof window.localStorage.favoriteTables !== 'undefined' + && window.localStorage.favoriteTables !== 'undefined') { + favoriteTables = window.localStorage.favoriteTables; + if (favoriteTables === 'undefined') { + // Do not send an invalid value + return; + } + } $.ajax({ url: $('#sync_favorite_tables').attr('href'), cache: false, type: 'POST', data: { - 'favoriteTables': (isStorageSupported('localStorage') && typeof window.localStorage.favoriteTables !== 'undefined') - ? window.localStorage.favoriteTables - : '', + 'favoriteTables': favoriteTables, 'server': CommonParams.get('server'), 'no_debug': true },