mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-19 02:10:04 +08:00
fix(touchbar): errors if there is no modal
This commit is contained in:
parent
d6478c2fed
commit
3fb2378de9
@ -15,7 +15,7 @@ export default class TouchBarWidget extends NoteContextAwareWidget {
|
|||||||
nativeImage: typeof import("electron").nativeImage;
|
nativeImage: typeof import("electron").nativeImage;
|
||||||
remote: typeof import("@electron/remote");
|
remote: typeof import("@electron/remote");
|
||||||
lastFocusedComponent?: Component;
|
lastFocusedComponent?: Component;
|
||||||
private $activeModal: JQuery<HTMLElement>;
|
private $activeModal?: JQuery<HTMLElement>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -57,7 +57,7 @@ export default class TouchBarWidget extends NoteContextAwareWidget {
|
|||||||
const parentComponent = this.lastFocusedComponent;
|
const parentComponent = this.lastFocusedComponent;
|
||||||
let touchBar = null;
|
let touchBar = null;
|
||||||
|
|
||||||
if (this.$activeModal.length > 0) {
|
if (this.$activeModal?.length) {
|
||||||
touchBar = this.#buildModalTouchBar();
|
touchBar = this.#buildModalTouchBar();
|
||||||
} else if (parentComponent) {
|
} else if (parentComponent) {
|
||||||
const items = parentComponent.triggerCommand("buildTouchBar", {
|
const items = parentComponent.triggerCommand("buildTouchBar", {
|
||||||
@ -78,16 +78,16 @@ export default class TouchBarWidget extends NoteContextAwareWidget {
|
|||||||
const items: TouchBarItem[] = [];
|
const items: TouchBarItem[] = [];
|
||||||
|
|
||||||
// Look for the modal title.
|
// Look for the modal title.
|
||||||
const $title = this.$activeModal.find(".modal-title");
|
const $title = this.$activeModal?.find(".modal-title");
|
||||||
if ($title.length > 0) {
|
if ($title?.length) {
|
||||||
items.push(new TouchBarLabel({ label: $title.text() }))
|
items.push(new TouchBarLabel({ label: $title.text() }))
|
||||||
}
|
}
|
||||||
|
|
||||||
items.push(new TouchBarSpacer({ size: "flexible" }));
|
items.push(new TouchBarSpacer({ size: "flexible" }));
|
||||||
|
|
||||||
// Look for buttons in the modal.
|
// Look for buttons in the modal.
|
||||||
const $buttons = this.$activeModal.find(".modal-footer button");
|
const $buttons = this.$activeModal?.find(".modal-footer button");
|
||||||
for (const button of $buttons) {
|
for (const button of $buttons ?? []) {
|
||||||
items.push(new TouchBarButton({
|
items.push(new TouchBarButton({
|
||||||
label: button.innerText,
|
label: button.innerText,
|
||||||
click: () => button.click(),
|
click: () => button.click(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user