1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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; return defaultValue;
} }
} }
function getLocal(key) {
return localStorage.getItem(key)
}
function setLocal(key, value) {
localStorage.setItem(key, value);
}
function removeLocal(key) {
localStorage.removeItem(key)
}
return { return {
init: init, init: init,
@ -228,6 +238,9 @@ RED.settings = (function () {
set: set, set: set,
get: get, get: get,
remove: remove, remove: remove,
theme: theme theme: theme,
setLocal: setLocal,
getLocal: getLocal,
removeLocal: removeLocal
} }
})(); })();

View File

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