Skip to content

Commit 5535446

Browse files
committed
Fix checking cookies for auto-saved query
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
1 parent 3357238 commit 5535446

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

resources/js/sql.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,20 +1307,11 @@ function getAutoSavedKey () {
13071307
}
13081308

13091309
function checkSavedQuery () {
1310-
let key = Sql.getAutoSavedKey();
1311-
let buttonGetAutoSavedQuery = $('#saved');
1312-
1313-
let isAutoSavedInLocalStorage = isStorageSupported('localStorage') && (typeof window.localStorage.getItem(key) === 'string');
1314-
// @ts-ignore
1315-
let isAutoSavedInCookie = window.Cookies.get(key, { path: CommonParams.get('rootPath') });
1316-
1317-
if (isAutoSavedInLocalStorage || isAutoSavedInCookie) {
1318-
buttonGetAutoSavedQuery.prop('disabled', false);
1319-
1320-
return;
1321-
}
1322-
1323-
buttonGetAutoSavedQuery.prop('disabled', true);
1310+
const key = Sql.getAutoSavedKey();
1311+
const haveAutoSavedQuery =
1312+
(isStorageSupported('localStorage') && typeof window.localStorage.getItem(key) === 'string') ||
1313+
window.Cookies.withAttributes({ path: CommonParams.get('rootPath') }).get(key);
1314+
$('#saved').prop('disabled', !haveAutoSavedQuery);
13241315
}
13251316

13261317
AJAX.registerOnload('sql.js', function () {

0 commit comments

Comments
 (0)