mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-01 04:32:26 +08:00
fix: 🐛 fix wrong triggerEvent usage
This commit is contained in:
parent
469c2c3ce9
commit
a9d8d7d3c5
@ -296,7 +296,7 @@ type EventMappings = {
|
|||||||
noteContext: NoteContext;
|
noteContext: NoteContext;
|
||||||
notePath?: string | null;
|
notePath?: string | null;
|
||||||
};
|
};
|
||||||
noteSwitchedAndActivatedEvent: {
|
noteSwitchedAndActivated: {
|
||||||
noteContext: NoteContext;
|
noteContext: NoteContext;
|
||||||
notePath: string;
|
notePath: string;
|
||||||
};
|
};
|
||||||
@ -326,7 +326,7 @@ type EventMappings = {
|
|||||||
noteId: string;
|
noteId: string;
|
||||||
ntxId: string | null;
|
ntxId: string | null;
|
||||||
};
|
};
|
||||||
contextsReopenedEvent: {
|
contextsReopened: {
|
||||||
mainNtxId: string | null;
|
mainNtxId: string | null;
|
||||||
tabPosition: number;
|
tabPosition: number;
|
||||||
};
|
};
|
||||||
@ -362,7 +362,7 @@ type EventMappings = {
|
|||||||
relationMapResetPanZoom: { ntxId: string | null | undefined };
|
relationMapResetPanZoom: { ntxId: string | null | undefined };
|
||||||
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
||||||
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
||||||
activeNoteChangedEvent: {};
|
activeNoteChanged: {};
|
||||||
showAddLinkDialog: {
|
showAddLinkDialog: {
|
||||||
textTypeWidget: EditableTextTypeWidget;
|
textTypeWidget: EditableTextTypeWidget;
|
||||||
text: string;
|
text: string;
|
||||||
|
@ -163,7 +163,7 @@ export default class TabManager extends Component {
|
|||||||
const activeNoteContext = this.getActiveContext();
|
const activeNoteContext = this.getActiveContext();
|
||||||
this.updateDocumentTitle(activeNoteContext);
|
this.updateDocumentTitle(activeNoteContext);
|
||||||
|
|
||||||
this.triggerEvent("activeNoteChangedEvent", {}); // trigger this even in on popstate event
|
this.triggerEvent("activeNoteChanged", {}); // trigger this even in on popstate event
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateHash(): string {
|
calculateHash(): string {
|
||||||
@ -338,7 +338,6 @@ export default class TabManager extends Component {
|
|||||||
const viewScope = opts.viewScope || { viewMode: "default" };
|
const viewScope = opts.viewScope || { viewMode: "default" };
|
||||||
|
|
||||||
const noteContext = await this.openEmptyTab(ntxId, hoistedNoteId, mainNtxId);
|
const noteContext = await this.openEmptyTab(ntxId, hoistedNoteId, mainNtxId);
|
||||||
|
|
||||||
if (notePath) {
|
if (notePath) {
|
||||||
await noteContext.setNote(notePath, {
|
await noteContext.setNote(notePath, {
|
||||||
// if activate is false, then send normal noteSwitched event
|
// if activate is false, then send normal noteSwitched event
|
||||||
@ -350,7 +349,7 @@ export default class TabManager extends Component {
|
|||||||
if (activate && noteContext.notePath) {
|
if (activate && noteContext.notePath) {
|
||||||
this.activateNoteContext(noteContext.ntxId, false);
|
this.activateNoteContext(noteContext.ntxId, false);
|
||||||
|
|
||||||
await this.triggerEvent("noteSwitchedAndActivatedEvent", {
|
await this.triggerEvent("noteSwitchedAndActivated", {
|
||||||
noteContext,
|
noteContext,
|
||||||
notePath: noteContext.notePath // resolved note path
|
notePath: noteContext.notePath // resolved note path
|
||||||
});
|
});
|
||||||
@ -647,13 +646,13 @@ export default class TabManager extends Component {
|
|||||||
let mainNtx = noteContexts.find((nc) => nc.isMainContext());
|
let mainNtx = noteContexts.find((nc) => nc.isMainContext());
|
||||||
if (mainNtx) {
|
if (mainNtx) {
|
||||||
// reopened a tab, need to reorder new tab widget in tab row
|
// reopened a tab, need to reorder new tab widget in tab row
|
||||||
await this.triggerEvent("contextsReopenedEvent", {
|
await this.triggerEvent("contextsReopened", {
|
||||||
mainNtxId: mainNtx.ntxId,
|
mainNtxId: mainNtx.ntxId,
|
||||||
tabPosition: ntxsInOrder.filter((nc) => nc.isMainContext()).findIndex((nc) => nc.ntxId === mainNtx.ntxId)
|
tabPosition: ntxsInOrder.filter((nc) => nc.isMainContext()).findIndex((nc) => nc.ntxId === mainNtx.ntxId)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// reopened a single split, need to reorder the pane widget in split note container
|
// reopened a single split, need to reorder the pane widget in split note container
|
||||||
await this.triggerEvent("contextsReopenedEvent", {
|
await this.triggerEvent("contextsReopened", {
|
||||||
mainNtxId: ntxsInOrder[lastClosedTab.position].ntxId,
|
mainNtxId: ntxsInOrder[lastClosedTab.position].ntxId,
|
||||||
// this is safe since lastClosedTab.position can never be 0 in this case
|
// this is safe since lastClosedTab.position can never be 0 in this case
|
||||||
tabPosition: lastClosedTab.position - 1
|
tabPosition: lastClosedTab.position - 1
|
||||||
|
@ -24,7 +24,7 @@ export default class ScrollingContainer extends Container<BasicWidget> {
|
|||||||
this.$widget.scrollTop(0);
|
this.$widget.scrollTop(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async noteSwitchedAndActivatedEvent({ noteContext, notePath }: EventData<"noteSwitchedAndActivatedEvent">) {
|
async noteSwitchedAndActivatedEvent({ noteContext, notePath }: EventData<"noteSwitchedAndActivated">) {
|
||||||
this.noteContext = noteContext;
|
this.noteContext = noteContext;
|
||||||
|
|
||||||
this.$widget.scrollTop(0);
|
this.$widget.scrollTop(0);
|
||||||
|
@ -199,7 +199,7 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.hasBeenAlreadyShown || name === "noteSwitchedAndActivatedEvent" || appContext.tabManager.getActiveMainContext() === noteContext.getMainContext()) {
|
if (widget.hasBeenAlreadyShown || name === "noteSwitchedAndActivated" || appContext.tabManager.getActiveMainContext() === noteContext.getMainContext()) {
|
||||||
widget.hasBeenAlreadyShown = true;
|
widget.hasBeenAlreadyShown = true;
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
@ -105,7 +105,7 @@ class NoteContextAwareWidget extends BasicWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when note is both switched and activated, this should not produce a double refresh
|
// when note is both switched and activated, this should not produce a double refresh
|
||||||
async noteSwitchedAndActivatedEvent({ noteContext, notePath }: EventData<"noteSwitchedAndActivatedEvent">) {
|
async noteSwitchedAndActivatedEvent({ noteContext, notePath }: EventData<"noteSwitchedAndActivated">) {
|
||||||
this.noteContext = noteContext;
|
this.noteContext = noteContext;
|
||||||
|
|
||||||
// if notePath does not match, then the noteContext has been switched to another note in the meantime
|
// if notePath does not match, then the noteContext has been switched to another note in the meantime
|
||||||
|
@ -628,7 +628,7 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
return closestIndex;
|
return closestIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
noteSwitchedAndActivatedEvent({ noteContext }: EventData<"noteSwitchedAndActivatedEvent">) {
|
noteSwitchedAndActivatedEvent({ noteContext }: EventData<"noteSwitchedAndActivated">) {
|
||||||
this.activeContextChangedEvent();
|
this.activeContextChangedEvent();
|
||||||
|
|
||||||
this.updateTabById(noteContext.mainNtxId || noteContext.ntxId);
|
this.updateTabById(noteContext.mainNtxId || noteContext.ntxId);
|
||||||
@ -649,7 +649,7 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
this.updateTabById(newMainNtxId);
|
this.updateTabById(newMainNtxId);
|
||||||
}
|
}
|
||||||
|
|
||||||
contextsReopenedEvent({ mainNtxId, tabPosition }: EventData<"contextsReopenedEvent">) {
|
contextsReopenedEvent({ mainNtxId, tabPosition }: EventData<"contextsReopened">) {
|
||||||
if (!mainNtxId || !tabPosition) {
|
if (!mainNtxId || !tabPosition) {
|
||||||
// no tab reopened
|
// no tab reopened
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user