|
|
|
@ -1,7 +1,9 @@
|
|
|
|
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
|
|
|
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
|
|
|
import appContext from "../../components/app_context.js";
|
|
|
|
import appContext, { type EventData, type EventNames } from "../../components/app_context.js";
|
|
|
|
|
|
|
|
import type FNote from "../../entities/fnote.js";
|
|
|
|
|
|
|
|
import type NoteDetailWidget from "../note_detail.js";
|
|
|
|
|
|
|
|
|
|
|
|
export default class TypeWidget extends NoteContextAwareWidget {
|
|
|
|
export default abstract class TypeWidget extends NoteContextAwareWidget {
|
|
|
|
// for overriding
|
|
|
|
// for overriding
|
|
|
|
static getType() {}
|
|
|
|
static getType() {}
|
|
|
|
|
|
|
|
|
|
|
|
@ -11,12 +13,11 @@ export default class TypeWidget extends NoteContextAwareWidget {
|
|
|
|
return super.doRender();
|
|
|
|
return super.doRender();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {FNote} note */
|
|
|
|
abstract doRefresh(note: FNote | null | undefined): Promise<void>;
|
|
|
|
async doRefresh(note) {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async refresh() {
|
|
|
|
async refresh() {
|
|
|
|
const thisWidgetType = this.constructor.getType();
|
|
|
|
const thisWidgetType = (this.constructor as any).getType();
|
|
|
|
const noteWidgetType = await this.parent.getWidgetType();
|
|
|
|
const noteWidgetType = await (this.parent as NoteDetailWidget).getWidgetType();
|
|
|
|
|
|
|
|
|
|
|
|
if (thisWidgetType !== noteWidgetType) {
|
|
|
|
if (thisWidgetType !== noteWidgetType) {
|
|
|
|
this.toggleInt(false);
|
|
|
|
this.toggleInt(false);
|
|
|
|
@ -27,7 +28,7 @@ export default class TypeWidget extends NoteContextAwareWidget {
|
|
|
|
|
|
|
|
|
|
|
|
await this.doRefresh(this.note);
|
|
|
|
await this.doRefresh(this.note);
|
|
|
|
|
|
|
|
|
|
|
|
this.triggerEvent("noteDetailRefreshed", { ntxId: this.noteContext.ntxId });
|
|
|
|
this.triggerEvent("noteDetailRefreshed", { ntxId: this.noteContext?.ntxId });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -40,7 +41,7 @@ export default class TypeWidget extends NoteContextAwareWidget {
|
|
|
|
|
|
|
|
|
|
|
|
focus() {}
|
|
|
|
focus() {}
|
|
|
|
|
|
|
|
|
|
|
|
async readOnlyTemporarilyDisabledEvent({ noteContext }) {
|
|
|
|
async readOnlyTemporarilyDisabledEvent({ noteContext }: EventData<"readOnlyTemporarilyDisabled">) {
|
|
|
|
if (this.isNoteContext(noteContext.ntxId)) {
|
|
|
|
if (this.isNoteContext(noteContext.ntxId)) {
|
|
|
|
await this.refresh();
|
|
|
|
await this.refresh();
|
|
|
|
|
|
|
|
|
|
|
|
@ -49,10 +50,10 @@ export default class TypeWidget extends NoteContextAwareWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// events should be propagated manually to the children widgets
|
|
|
|
// events should be propagated manually to the children widgets
|
|
|
|
handleEventInChildren(name, data) {
|
|
|
|
handleEventInChildren<T extends EventNames>(name: T, data: EventData<T>) {
|
|
|
|
if (["activeContextChanged", "setNoteContext"].includes(name)) {
|
|
|
|
if (["activeContextChanged", "setNoteContext"].includes(name)) {
|
|
|
|
// won't trigger .refresh();
|
|
|
|
// won't trigger .refresh();
|
|
|
|
return super.handleEventInChildren("setNoteContext", data);
|
|
|
|
return super.handleEventInChildren("setNoteContext", data as EventData<"activeContextChanged">);
|
|
|
|
} else if (name === "entitiesReloaded") {
|
|
|
|
} else if (name === "entitiesReloaded") {
|
|
|
|
return super.handleEventInChildren(name, data);
|
|
|
|
return super.handleEventInChildren(name, data);
|
|
|
|
} else {
|
|
|
|
} else {
|