refactor: extract shared logic to active note state

This commit is contained in:
Antonella Sgarlatta
2021-06-02 17:57:37 -03:00
parent 3db87099e0
commit 6fb68d2255
8 changed files with 184 additions and 164 deletions

View File

@@ -169,6 +169,6 @@
default-width="300"
hoverable="true"
on-resize-finish="self.onPanelResize"
on-width-event="self.onPanelWidthEvent"
on-mouse-move-event="self.onPanelMouseMoveEvent"
panel-id="'notes-column'"
)

View File

@@ -93,7 +93,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
};
this.onWindowResize = this.onWindowResize.bind(this);
this.onPanelResize = this.onPanelResize.bind(this);
this.onPanelWidthEvent = this.onPanelWidthEvent.bind(this);
this.onPanelMouseMoveEvent = this.onPanelMouseMoveEvent.bind(this);
window.addEventListener('resize', this.onWindowResize, true);
this.registerKeyboardShortcuts();
this.autorun(async () => {
@@ -134,7 +134,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
window.removeEventListener('resize', this.onWindowResize, true);
(this.onWindowResize as any) = undefined;
(this.onPanelResize as any) = undefined;
(this.onPanelWidthEvent as any) = undefined;
(this.onPanelMouseMoveEvent as any) = undefined;
this.newNoteKeyObserver();
this.nextNoteKeyObserver();
this.previousNoteKeyObserver();
@@ -659,8 +659,8 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
);
}
onPanelWidthEvent(): void {
this.appState.activeNote.reloadTagsContainerLayout();
onPanelMouseMoveEvent(): void {
this.appState.activeNote.reloadTagsContainerMaxWidth();
}
paginate() {