Skip to content

Commit de071bc

Browse files
authored
Merge pull request #2302 from spracing/rework-last-tab
Allows the user to always open the last tab that was used *before* the CLI tab.
2 parents 5444ce3 + c0f66a5 commit de071bc

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/js/gui.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,11 @@ GuiControl.prototype.content_ready = function (callback) {
388388

389389
GuiControl.prototype.selectDefaultTabWhenConnected = function() {
390390
ConfigStorage.get(['rememberLastTab', 'lastTab'], function (result) {
391-
if (!(result.rememberLastTab
392-
&& !!result.lastTab
393-
&& result.lastTab.substring(4) !== "cli")) {
391+
if (result.rememberLastTab && result.lastTab) {
392+
$(`#tabs ul.mode-connected .${result.lastTab} a`).click();
393+
} else {
394394
$('#tabs ul.mode-connected .tab_setup a').click();
395-
return;
396395
}
397-
$(`#tabs ul.mode-connected .${result.lastTab} a`).click();
398396
});
399397
};
400398

src/js/main.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,15 @@ function startProcess() {
219219
// Tabs
220220
$("#tabs ul.mode-connected li").click(function() {
221221
// store the first class of the current tab (omit things like ".active")
222-
ConfigStorage.set(
223-
{lastTab: $(this).attr("class").split(' ')[0]}
224-
);
222+
const tabName = $(this).attr("class").split(' ')[0];
223+
224+
const tabNameWithoutPrefix = tabName.substring(4);
225+
if (tabNameWithoutPrefix !== "cli") {
226+
// Don't store 'cli' otherwise you can never connect to another tab.
227+
ConfigStorage.set(
228+
{lastTab: tabName},
229+
);
230+
}
225231
});
226232

227233
if (GUI.isCordova()) {

0 commit comments

Comments
 (0)