Skip to content

Commit 79334ae

Browse files
feat: fix delete workspace on reload (#723)
* feat: fix delete workspace on reload * Update src/main.js --------- Co-authored-by: Mark Haslinghuis <[email protected]>
1 parent 386f6c8 commit 79334ae

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,24 @@ function BlackboxLogViewer() {
10591059
}
10601060

10611061
graphLegend = new GraphLegend($(".log-graph-legend"), activeGraphConfig, onLegendVisbilityChange, onLegendSelectionChange, onLegendHighlightChange, zoomGraphConfig, expandGraphConfig, newGraphConfig);
1062+
1063+
// initial load of the configuration defaults if we have them
1064+
prefs.get('workspaceGraphConfigs', function(item) {
1065+
if (item) {
1066+
workspaceGraphConfigs = upgradeWorkspaceFormat(item);
1067+
} else {
1068+
workspaceGraphConfigs = [];
1069+
}
1070+
});
1071+
1072+
prefs.get('activeWorkspace', function (id){
1073+
if (id) {
1074+
activeWorkspace = id
1075+
}
1076+
else {
1077+
activeWorkspace = 1
1078+
}
1079+
});
10621080

10631081
workspaceSelection = new WorkspaceSelection($(".log-workspace-selection"), workspaceGraphConfigs, onSwitchWorkspace, onSaveWorkspace);
10641082
onSwitchWorkspace(workspaceGraphConfigs, workspaceSelection);

src/workspace_selection.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const UNTITLED = "Untitled";
2+
13
export function WorkspaceSelection(targetElem, workspaces, onSelectionChange, onSaveWorkspace) {
24
var
35
numberSpan = null,
@@ -39,7 +41,7 @@ export function WorkspaceSelection(targetElem, workspaces, onSelectionChange, on
3941
var inputElem = $('<input type="text" onkeyup="event.preventDefault()">');
4042
inputElem.click((e) => e.stopPropagation()); // Stop click from closing
4143
titleSpan.replaceWith(inputElem);
42-
inputElem.val(workspaces[activeId].title)
44+
inputElem.val(workspaces[activeId]?.title)
4345
inputElem.focus();
4446
inputElem.on('focusout', () => {
4547
inputElem.replaceWith(titleSpan);
@@ -88,7 +90,7 @@ export function WorkspaceSelection(targetElem, workspaces, onSelectionChange, on
8890
var saveButton = $('<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true" data-toggle="tooltip" title="Save current graph setup to this Workspace"></span>');
8991
saveButton.click((e) => {
9092
if (!element) {
91-
onSaveWorkspace(id, "Unnamed");
93+
onSaveWorkspace(id, UNTITLED);
9294
}
9395
else {
9496
onSaveWorkspace(id, element.title);

0 commit comments

Comments
 (0)