Track hidden tabs in localStorage

This commit is contained in:
Nick O'Leary 2021-08-31 15:19:04 +01:00
parent ed8e7afdf6
commit 7026df7d96
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 25 additions and 1 deletions

View File

@ -220,6 +220,16 @@ RED.settings = (function () {
return defaultValue;
}
}
function getLocal(key) {
return localStorage.getItem(key)
}
function setLocal(key, value) {
localStorage.setItem(key, value);
}
function removeLocal(key) {
localStorage.removeItem(key)
}
return {
init: init,
@ -228,6 +238,9 @@ RED.settings = (function () {
set: set,
get: get,
remove: remove,
theme: theme
theme: theme,
setLocal: setLocal,
getLocal: getLocal,
removeLocal: removeLocal
}
})();

View File

@ -57,6 +57,11 @@ RED.workspaces = (function() {
ws.hideable = true;
}
workspace_tabs.addTab(ws,targetIndex);
var hiddenTabs = JSON.parse(RED.settings.getLocal("hiddenTabs")||"{}");
if (hiddenTabs[ws.id]) {
workspace_tabs.hideTab(ws.id);
}
workspace_tabs.resize();
} else {
var tabId = RED.nodes.id();
@ -664,6 +669,9 @@ RED.workspaces = (function() {
}
if (workspace_tabs.contains(id)) {
workspace_tabs.hideTab(id);
var hiddenTabs = JSON.parse(RED.settings.getLocal("hiddenTabs")||"{}");
hiddenTabs[id] = true;
RED.settings.setLocal("hiddenTabs",JSON.stringify(hiddenTabs));
}
},
show: function(id,skipStack,unhideOnly) {
@ -688,6 +696,9 @@ RED.workspaces = (function() {
}
workspace_tabs.activateTab(id);
}
var hiddenTabs = JSON.parse(RED.settings.getLocal("hiddenTabs")||"{}");
delete hiddenTabs[id];
RED.settings.setLocal("hiddenTabs",JSON.stringify(hiddenTabs));
},
refresh: function() {
RED.nodes.eachWorkspace(function(ws) {