fix new tab open hiding

pull/255/head
zadam 2020-03-15 11:08:16 +07:00
parent 687a466a35
commit 2cc0442ef2
3 changed files with 534 additions and 472 deletions

924
package-lock.json generated

File diff suppressed because it is too large Load Diff

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

@ -13,32 +13,6 @@ export default class TabCachingWidget extends TabAwareWidget {
return this.$widget = $(`<div class="marker" style="display: none;">`);
}
handleEventInChildren(name, data) {
// stop propagation of the event to the children, individual tab widget should not know about tab switching
// since they are per-tab
if (name === 'tabNoteSwitchedAndActivated') {
name = 'tabNoteSwitched';
}
if (name === 'tabNoteSwitched') {
// this event is propagated only to the widgets of a particular tab
const widget = this.widgets[data.tabContext.tabId];
if (widget) {
return widget.handleEvent(name, data);
}
else {
return Promise.resolve();
}
}
if (name !== 'activeTabChanged') {
return super.handleEventInChildren(name, data);
}
return Promise.resolve();
}
async newTabOpenedEvent({tabContext}) {
const {tabId} = tabContext;
@ -49,7 +23,7 @@ export default class TabCachingWidget extends TabAwareWidget {
this.widgets[tabId] = this.widgetFactory();
const $renderedWidget = this.widgets[tabId].render();
this.widgets[tabId].toggleExt(this.widgets[tabId]);
this.widgets[tabId].toggleExt(this.isTab(tabId));
this.$widget.after($renderedWidget);
@ -60,14 +34,6 @@ export default class TabCachingWidget extends TabAwareWidget {
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];
@ -79,11 +45,41 @@ export default class TabCachingWidget extends TabAwareWidget {
}
}
async refresh() {
this.toggleExt(true);
}
toggleInt(show) {} // not needed
toggleByTab(show) {
toggleExt(show) {
for (const tabId in this.widgets) {
this.widgets[tabId].toggleExt(show && this.isTab(tabId));
}
}
handleEventInChildren(name, data) {
// stop propagation of the event to the children, individual tab widget should not know about tab switching
// since they are per-tab
if (name === 'tabNoteSwitchedAndActivated') {
name = 'tabNoteSwitched';
}
if (name === 'tabNoteSwitched') {
// this event is propagated only to the widgets of a particular tab
const widget = this.widgets[data.tabContext.tabId];
if (widget) {
return widget.handleEvent(name, data);
}
else {
return Promise.resolve();
}
}
if (name !== 'activeTabChanged') {
return super.handleEventInChildren(name, data);
}
return Promise.resolve();
}
}