fix new tab open hiding

This commit is contained in:
zadam 2020-03-15 11:08:16 +01:00
parent 687a466a35
commit 2cc0442ef2
3 changed files with 547 additions and 485 deletions

920
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@
"body-parser": "1.19.0", "body-parser": "1.19.0",
"cls-hooked": "4.2.2", "cls-hooked": "4.2.2",
"commonmark": "0.29.1", "commonmark": "0.29.1",
"cookie-parser": "1.4.4", "cookie-parser": "1.4.5",
"csurf": "1.11.0", "csurf": "1.11.0",
"dayjs": "1.8.22", "dayjs": "1.8.22",
"debug": "4.1.1", "debug": "4.1.1",
@ -36,7 +36,7 @@
"electron-window-state": "5.0.3", "electron-window-state": "5.0.3",
"express": "4.17.1", "express": "4.17.1",
"express-session": "1.17.0", "express-session": "1.17.0",
"file-type": "14.1.3", "file-type": "14.1.4",
"fs-extra": "8.1.0", "fs-extra": "8.1.0",
"helmet": "3.21.3", "helmet": "3.21.3",
"html": "1.0.0", "html": "1.0.0",
@ -56,7 +56,7 @@
"open": "7.0.3", "open": "7.0.3",
"portscanner": "2.2.0", "portscanner": "2.2.0",
"rand-token": "0.4.0", "rand-token": "0.4.0",
"rcedit": "2.1.0", "rcedit": "2.1.1",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"sanitize-filename": "1.6.3", "sanitize-filename": "1.6.3",
"sax": "1.2.4", "sax": "1.2.4",
@ -67,17 +67,17 @@
"sqlite": "3.0.3", "sqlite": "3.0.3",
"sqlite3": "4.1.1", "sqlite3": "4.1.1",
"string-similarity": "4.0.1", "string-similarity": "4.0.1",
"tar-stream": "2.1.1", "tar-stream": "2.1.2",
"turndown": "5.0.3", "turndown": "6.0.0",
"turndown-plugin-gfm": "1.0.2", "turndown-plugin-gfm": "1.0.2",
"unescape": "1.0.1", "unescape": "1.0.1",
"ws": "7.2.3" "ws": "7.2.3"
}, },
"devDependencies": { "devDependencies": {
"electron": "9.0.0-beta.7", "electron": "9.0.0-beta.7",
"electron-builder": "22.4.0", "electron-builder": "22.4.1",
"electron-packager": "14.2.1", "electron-packager": "14.2.1",
"electron-rebuild": "1.10.0", "electron-rebuild": "1.10.1",
"jsdoc": "3.6.3", "jsdoc": "3.6.3",
"lorem-ipsum": "2.0.3" "lorem-ipsum": "2.0.3"
}, },

View File

@ -13,6 +13,50 @@ export default class TabCachingWidget extends TabAwareWidget {
return this.$widget = $(`<div class="marker" style="display: none;">`); return this.$widget = $(`<div class="marker" style="display: none;">`);
} }
async newTabOpenedEvent({tabContext}) {
const {tabId} = tabContext;
if (this.widgets[tabId]) {
return;
}
this.widgets[tabId] = this.widgetFactory();
const $renderedWidget = this.widgets[tabId].render();
this.widgets[tabId].toggleExt(this.isTab(tabId));
this.$widget.after($renderedWidget);
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
await this.widgets[tabId].handleEvent('setTabContext', {tabContext});
this.child(this.widgets[tabId]); // add as child only once it is ready (rendered with tabContext)
}
tabRemovedEvent({tabId}) {
const widget = this.widgets[tabId];
if (widget) {
widget.remove();
delete this.widgets[tabId];
this.children = this.children.filter(ch => ch !== widget);
}
}
async refresh() {
this.toggleExt(true);
}
toggleInt(show) {} // not needed
toggleExt(show) {
for (const tabId in this.widgets) {
this.widgets[tabId].toggleExt(show && this.isTab(tabId));
}
}
handleEventInChildren(name, data) { handleEventInChildren(name, data) {
// stop propagation of the event to the children, individual tab widget should not know about tab switching // stop propagation of the event to the children, individual tab widget should not know about tab switching
// since they are per-tab // since they are per-tab
@ -38,52 +82,4 @@ export default class TabCachingWidget extends TabAwareWidget {
return Promise.resolve(); return Promise.resolve();
} }
async newTabOpenedEvent({tabContext}) {
const {tabId} = tabContext;
if (this.widgets[tabId]) {
return;
}
this.widgets[tabId] = this.widgetFactory();
const $renderedWidget = this.widgets[tabId].render();
this.widgets[tabId].toggleExt(this.widgets[tabId]);
this.$widget.after($renderedWidget);
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
await this.widgets[tabId].handleEvent('setTabContext', {tabContext});
this.child(this.widgets[tabId]); // add as child only once it is ready (rendered with tabContext)
}
async refresh() {
const activeTabId = this.tabContext && this.tabContext.tabId;
for (const tabId in this.widgets) {
this.widgets[tabId].toggleExt(tabId === activeTabId);
}
}
tabRemovedEvent({tabId}) {
const widget = this.widgets[tabId];
if (widget) {
widget.remove();
delete this.widgets[tabId];
this.children = this.children.filter(ch => ch !== widget);
}
}
toggleInt(show) {} // not needed
toggleByTab(show) {
for (const tabId in this.widgets) {
this.widgets[tabId].toggleExt(show && this.isTab(tabId));
}
}
} }