From 07678bbd3245c6768fa749ed47d725e0dfdd11a0 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 27 Dec 2021 15:23:56 -0600 Subject: [PATCH 1/9] fix: showing saving status on first load --- app/assets/javascripts/views/editor/editor_view.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index dbc8b4d3b..5289cd670 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -214,6 +214,7 @@ export class EditorViewCtrl extends PureViewCtrl { ) { this.showSavingStatus(); } else if ( + this.state.noteStatus && note.lastSyncEnd!.getTime() > note.lastSyncBegan!.getTime() ) { this.showAllChangesSavedStatus(); From c9e448c7b640d80b5a7c9277e11500bf9fef5284 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 27 Dec 2021 15:42:48 -0600 Subject: [PATCH 2/9] fix: focus new note on create (#791) --- .../javascripts/ui_models/app_state/notes_view_state.ts | 8 ++------ app/assets/javascripts/views/editor/editor_view.ts | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/ui_models/app_state/notes_view_state.ts b/app/assets/javascripts/ui_models/app_state/notes_view_state.ts index 62a5f6047..e578e1a29 100644 --- a/app/assets/javascripts/ui_models/app_state/notes_view_state.ts +++ b/app/assets/javascripts/ui_models/app_state/notes_view_state.ts @@ -318,7 +318,7 @@ export class NotesViewState { } }; - createNewNote = async (focusNewNote = true) => { + createNewNote = async () => { this.appState.notes.unselectNotes(); let title = `Note ${this.notes.length + 1}`; if (this.isFiltering) { @@ -327,10 +327,6 @@ export class NotesViewState { await this.appState.createEditor(title); this.reloadNotes(); this.appState.noteTags.reloadTags(); - const noteTitleEditorElement = document.getElementById('note-title-editor'); - if (focusNewNote) { - noteTitleEditorElement?.focus(); - } }; createPlaceholderNote = () => { @@ -338,7 +334,7 @@ export class NotesViewState { if (selectedTag && selectedTag.isSmartTag && !selectedTag.isAllTag) { return; } - return this.createNewNote(false); + return this.createNewNote(); }; get optionsSubtitle(): string { diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index 5289cd670..23ddc4409 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -183,6 +183,12 @@ export class EditorViewCtrl extends PureViewCtrl { if (this.note.dirty) { this.showSavingStatus(); } + + if (this.editor.isTemplateNote) { + this.$timeout(() => { + this.focusTitle(); + }); + } } private onNoteChanges(note: SNNote, source: PayloadSource): void { From 3140b17c20a3af01e9277336d8f942305c7e1646 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 27 Dec 2021 16:01:45 -0600 Subject: [PATCH 3/9] fix: only create new placeholder if no editor is open --- app/assets/javascripts/ui_models/app_state/notes_view_state.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/ui_models/app_state/notes_view_state.ts b/app/assets/javascripts/ui_models/app_state/notes_view_state.ts index e578e1a29..bebe40d8a 100644 --- a/app/assets/javascripts/ui_models/app_state/notes_view_state.ts +++ b/app/assets/javascripts/ui_models/app_state/notes_view_state.ts @@ -111,7 +111,8 @@ export class NotesViewState { if ( this.notes.length === 0 && this.appState.selectedTag?.isAllTag && - this.noteFilterText === '' + this.noteFilterText === '' && + !this.appState.notes.activeEditor ) { this.createPlaceholderNote(); } From 06fae3acda0909ec1ad03771be978773fa9ba178 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 27 Dec 2021 16:29:18 -0600 Subject: [PATCH 4/9] fix: debounce editor reloading to handle fast fire --- .../javascripts/views/editor/editor_view.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index 23ddc4409..6f96c0df3 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -21,7 +21,7 @@ import { ItemMutator, ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction, } from '@standardnotes/snjs'; -import { isDesktopApplication } from '@/utils'; +import { debounce, isDesktopApplication } from '@/utils'; import { KeyboardModifier, KeyboardKey } from '@/services/ioService'; import template from './editor-view.pug'; import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl'; @@ -130,6 +130,10 @@ export class EditorViewCtrl extends PureViewCtrl { this.onEditorLoad = () => { this.application.getDesktopService().redoSearch(); }; + this.debounceReloadEditorComponent = debounce( + this.debounceReloadEditorComponent.bind(this), + 25 + ); } deinit() { @@ -180,10 +184,6 @@ export class EditorViewCtrl extends PureViewCtrl { this.reloadPreferences(); - if (this.note.dirty) { - this.showSavingStatus(); - } - if (this.editor.isTemplateNote) { this.$timeout(() => { this.focusTitle(); @@ -383,7 +383,7 @@ export class EditorViewCtrl extends PureViewCtrl { } if (!this.note) return; await this.reloadStackComponents(); - await this.reloadEditorComponent(); + this.debounceReloadEditorComponent(); } ); } @@ -410,6 +410,14 @@ export class EditorViewCtrl extends PureViewCtrl { }); } + /** + * Calling reloadEditorComponent successively without waiting for state to settle + * can result in componentViewers being dealloced twice + */ + debounceReloadEditorComponent() { + this.reloadEditorComponent(); + } + private async reloadEditorComponent() { const newEditor = this.application.componentManager.editorForNote( this.note From 54e5fc918478eb53c04a7b0b542bc07a175cbfa1 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 27 Dec 2021 18:23:53 -0600 Subject: [PATCH 5/9] fix: associate new note with default editor --- app/assets/javascripts/views/editor/editor_view.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index 6f96c0df3..dd7990779 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -425,6 +425,7 @@ export class EditorViewCtrl extends PureViewCtrl { /** Editors cannot interact with template notes so the note must be inserted */ if (newEditor && this.editor.isTemplateNote) { await this.editor.insertTemplatedNote(); + this.associateComponentWithCurrentNote(newEditor); } const currentComponentViewer = this.state.editorComponentViewer; From 15aea42d4fbd0c03a677a0aad8f74f242c880e9d Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 27 Dec 2021 18:46:56 -0600 Subject: [PATCH 6/9] chore: rename editor model to note controller --- .../ui_models/app_state/app_state.ts | 48 +++++------ .../ui_models/app_state/note_tags_state.ts | 2 +- .../ui_models/app_state/notes_state.ts | 18 ++-- .../ui_models/app_state/notes_view_state.ts | 16 ++-- .../javascripts/ui_models/application.ts | 8 +- .../javascripts/ui_models/editor_group.ts | 79 ----------------- .../{editor.ts => note_controller.ts} | 41 ++++----- .../ui_models/note_controller_group.ts | 84 +++++++++++++++++++ .../javascripts/views/editor/editor-view.pug | 2 +- .../javascripts/views/editor/editor_view.ts | 38 ++++----- .../views/editor_group/editor-group-view.pug | 4 +- .../views/editor_group/editor_group_view.ts | 26 +++--- 12 files changed, 184 insertions(+), 182 deletions(-) delete mode 100644 app/assets/javascripts/ui_models/editor_group.ts rename app/assets/javascripts/ui_models/{editor.ts => note_controller.ts} (70%) create mode 100644 app/assets/javascripts/ui_models/note_controller_group.ts diff --git a/app/assets/javascripts/ui_models/app_state/app_state.ts b/app/assets/javascripts/ui_models/app_state/app_state.ts index 4d1ce9806..e413c2922 100644 --- a/app/assets/javascripts/ui_models/app_state/app_state.ts +++ b/app/assets/javascripts/ui_models/app_state/app_state.ts @@ -2,7 +2,7 @@ import { Bridge } from '@/services/bridge'; import { storage, StorageKey } from '@/services/localStorage'; import { WebApplication } from '@/ui_models/application'; import { AccountMenuState } from '@/ui_models/app_state/account_menu_state'; -import { Editor } from '@/ui_models/editor'; +import { NoteController } from '@/ui_models/note_controller'; import { isDesktopApplication } from '@/utils'; import { ApplicationEvent, @@ -226,9 +226,9 @@ export class AppState { storage.set(StorageKey.ShowBetaWarning, true); } - async createEditor(title?: string) { + async openNewNote(title?: string) { if (!this.multiEditorSupport) { - this.closeActiveEditor(); + this.closeActiveNoteController(); } const activeTagUuid = this.selectedTag ? this.selectedTag.isSmartTag @@ -236,37 +236,37 @@ export class AppState { : this.selectedTag.uuid : undefined; - await this.application.editorGroup.createEditor( + await this.application.noteControllerGroup.createNoteController( undefined, title, activeTagUuid ); } - getActiveEditor() { - return this.application.editorGroup.editors[0]; + getActiveNoteController() { + return this.application.noteControllerGroup.noteControllers[0]; } - getEditors() { - return this.application.editorGroup.editors; + getNoteControllers() { + return this.application.noteControllerGroup.noteControllers; } - closeEditor(editor: Editor) { - this.application.editorGroup.closeEditor(editor); + closeNoteController(controller: NoteController) { + this.application.noteControllerGroup.closeController(controller); } - closeActiveEditor() { - this.application.editorGroup.closeActiveEditor(); + closeActiveNoteController() { + this.application.noteControllerGroup.closeActiveController(); } - closeAllEditors() { - this.application.editorGroup.closeAllEditors(); + closeAllNoteControllers() { + this.application.noteControllerGroup.closeAllControllers(); } - editorForNote(note: SNNote) { - for (const editor of this.getEditors()) { - if (editor.note.uuid === note.uuid) { - return editor; + noteControllerForNote(note: SNNote) { + for (const controller of this.getNoteControllers()) { + if (controller.note.uuid === note.uuid) { + return controller; } } } @@ -275,31 +275,31 @@ export class AppState { this.application.streamItems( [ContentType.Note, ContentType.Tag], async (items, source) => { - /** Close any editors for deleted/trashed/archived notes */ + /** Close any note controllers for deleted/trashed/archived notes */ if (source === PayloadSource.PreSyncSave) { const notes = items.filter( (candidate) => candidate.content_type === ContentType.Note ) as SNNote[]; for (const note of notes) { - const editor = this.editorForNote(note); - if (!editor) { + const noteController = this.noteControllerForNote(note); + if (!noteController) { continue; } if (note.deleted) { - this.closeEditor(editor); + this.closeNoteController(noteController); } else if ( note.trashed && !this.selectedTag?.isTrashTag && !this.searchOptions.includeTrashed ) { - this.closeEditor(editor); + this.closeNoteController(noteController); } else if ( note.archived && !this.selectedTag?.isArchiveTag && !this.searchOptions.includeArchived && !this.application.getPreference(PrefKey.NotesShowArchived, false) ) { - this.closeEditor(editor); + this.closeNoteController(noteController); } } } diff --git a/app/assets/javascripts/ui_models/app_state/note_tags_state.ts b/app/assets/javascripts/ui_models/app_state/note_tags_state.ts index b49699c50..f24a08936 100644 --- a/app/assets/javascripts/ui_models/app_state/note_tags_state.ts +++ b/app/assets/javascripts/ui_models/app_state/note_tags_state.ts @@ -48,7 +48,7 @@ export class NoteTagsState { } get activeNote(): SNNote | undefined { - return this.appState.notes.activeEditor?.note; + return this.appState.notes.activeNoteController?.note; } get autocompleteTagHintVisible(): boolean { diff --git a/app/assets/javascripts/ui_models/app_state/notes_state.ts b/app/assets/javascripts/ui_models/app_state/notes_state.ts index f38ea99ed..05859a376 100644 --- a/app/assets/javascripts/ui_models/app_state/notes_state.ts +++ b/app/assets/javascripts/ui_models/app_state/notes_state.ts @@ -17,7 +17,7 @@ import { runInAction, } from 'mobx'; import { WebApplication } from '../application'; -import { Editor } from '../editor'; +import { NoteController } from '../note_controller'; import { AppState } from './app_state'; export class NotesState { @@ -68,8 +68,8 @@ export class NotesState { ); } - get activeEditor(): Editor | undefined { - return this.application.editorGroup.editors[0]; + get activeNoteController(): NoteController | undefined { + return this.application.noteControllerGroup.noteControllers[0]; } get selectedNotesCount(): number { @@ -151,13 +151,13 @@ export class NotesState { } if (this.selectedNotesCount === 1) { - await this.openEditor(Object.keys(this.selectedNotes)[0]); + await this.openNote(Object.keys(this.selectedNotes)[0]); } } } - private async openEditor(noteUuid: string): Promise { - if (this.activeEditor?.note?.uuid === noteUuid) { + private async openNote(noteUuid: string): Promise { + if (this.activeNoteController?.note?.uuid === noteUuid) { return; } @@ -167,11 +167,11 @@ export class NotesState { return; } - if (this.activeEditor) { - this.application.editorGroup.closeActiveEditor(); + if (this.activeNoteController) { + this.application.noteControllerGroup.closeActiveController(); } - await this.application.editorGroup.createEditor(noteUuid); + await this.application.noteControllerGroup.createNoteController(noteUuid); this.appState.noteTags.reloadTags(); await this.onActiveEditorChanged(); diff --git a/app/assets/javascripts/ui_models/app_state/notes_view_state.ts b/app/assets/javascripts/ui_models/app_state/notes_view_state.ts index bebe40d8a..e0be2a0e0 100644 --- a/app/assets/javascripts/ui_models/app_state/notes_view_state.ts +++ b/app/assets/javascripts/ui_models/app_state/notes_view_state.ts @@ -70,7 +70,7 @@ export class NotesViewState { appObservers.push( application.streamItems(ContentType.Note, () => { this.reloadNotes(); - const activeNote = this.appState.notes.activeEditor?.note; + const activeNote = this.appState.notes.activeNoteController?.note; if (this.application.getAppState().notes.selectedNotesCount < 2) { if (activeNote) { const discarded = activeNote.deleted || activeNote.trashed; @@ -102,7 +102,7 @@ export class NotesViewState { this.reloadPreferences(); }, ApplicationEvent.PreferencesChanged), application.addEventObserver(async () => { - this.appState.closeAllEditors(); + this.appState.closeAllNoteControllers(); this.selectFirstNote(); this.setCompletedFullSync(false); }, ApplicationEvent.SignedIn), @@ -112,7 +112,7 @@ export class NotesViewState { this.notes.length === 0 && this.appState.selectedTag?.isAllTag && this.noteFilterText === '' && - !this.appState.notes.activeEditor + !this.appState.notes.activeNoteController ) { this.createPlaceholderNote(); } @@ -192,7 +192,7 @@ export class NotesViewState { } get activeEditorNote() { - return this.appState.notes.activeEditor?.note; + return this.appState.notes.activeNoteController?.note; } reloadPanelTitle = () => { @@ -325,7 +325,7 @@ export class NotesViewState { if (this.isFiltering) { title = this.noteFilterText; } - await this.appState.createEditor(title); + await this.appState.openNewNote(title); this.reloadNotes(); this.appState.noteTags.reloadTags(); }; @@ -433,7 +433,7 @@ export class NotesViewState { if (note) { this.selectNote(note, false, false); } else { - this.appState.closeActiveEditor(); + this.appState.closeActiveNoteController(); } }; @@ -464,7 +464,7 @@ export class NotesViewState { }; handleEditorChange = async () => { - const activeNote = this.appState.getActiveEditor()?.note; + const activeNote = this.appState.getActiveNoteController()?.note; if (activeNote && activeNote.conflictOf) { this.application.changeAndSaveItem(activeNote.uuid, (mutator) => { mutator.conflictOf = undefined; @@ -502,7 +502,7 @@ export class NotesViewState { this.activeEditorNote && !this.notes.includes(this.activeEditorNote) ) { - this.appState.closeActiveEditor(); + this.appState.closeActiveNoteController(); } } }; diff --git a/app/assets/javascripts/ui_models/application.ts b/app/assets/javascripts/ui_models/application.ts index a0709260d..5a9ac004d 100644 --- a/app/assets/javascripts/ui_models/application.ts +++ b/app/assets/javascripts/ui_models/application.ts @@ -10,7 +10,7 @@ import { StatusManager } from '@/services/statusManager'; import { ThemeManager } from '@/services/themeManager'; import { PasswordWizardScope, PasswordWizardType } from '@/types'; import { AppState } from '@/ui_models/app_state'; -import { EditorGroup } from '@/ui_models/editor_group'; +import { NoteControllerGroup } from '@/ui_models/note_controller_group'; import { AppVersion } from '@/version'; import { WebDeviceInterface } from '@/web_device_interface'; import { @@ -36,7 +36,7 @@ export class WebApplication extends SNApplication { private scope?: angular.IScope; private webServices!: WebServices; private currentAuthenticationElement?: angular.IRootElementService; - public editorGroup: EditorGroup; + public noteControllerGroup: NoteControllerGroup; /* @ngInject */ constructor( @@ -66,7 +66,7 @@ export class WebApplication extends SNApplication { this.$compile = $compile; this.scope = scope; deviceInterface.setApplication(this); - this.editorGroup = new EditorGroup(this); + this.noteControllerGroup = new NoteControllerGroup(this); this.presentPermissionsDialog = this.presentPermissionsDialog.bind(this); } @@ -80,7 +80,7 @@ export class WebApplication extends SNApplication { } this.webServices = {} as WebServices; (this.$compile as unknown) = undefined; - this.editorGroup.deinit(); + this.noteControllerGroup.deinit(); (this.scope as any).application = undefined; this.scope!.$destroy(); this.scope = undefined; diff --git a/app/assets/javascripts/ui_models/editor_group.ts b/app/assets/javascripts/ui_models/editor_group.ts deleted file mode 100644 index 577478036..000000000 --- a/app/assets/javascripts/ui_models/editor_group.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { removeFromArray, UuidString } from '@standardnotes/snjs'; -import { Editor } from './editor'; -import { WebApplication } from './application'; - -type EditorGroupChangeCallback = () => void; - -export class EditorGroup { - public editors: Editor[] = []; - private application: WebApplication; - changeObservers: EditorGroupChangeCallback[] = []; - - constructor(application: WebApplication) { - this.application = application; - } - - public deinit() { - (this.application as unknown) = undefined; - for (const editor of this.editors) { - this.deleteEditor(editor); - } - } - - async createEditor( - noteUuid?: string, - noteTitle?: string, - noteTag?: UuidString - ) { - const editor = new Editor(this.application, noteUuid, noteTitle, noteTag); - await editor.initialize(); - this.editors.push(editor); - this.notifyObservers(); - } - - deleteEditor(editor: Editor) { - editor.deinit(); - removeFromArray(this.editors, editor); - } - - closeEditor(editor: Editor) { - this.deleteEditor(editor); - this.notifyObservers(); - } - - closeActiveEditor() { - const activeEditor = this.activeEditor; - if (activeEditor) { - this.deleteEditor(activeEditor); - } - } - - closeAllEditors() { - for (const editor of this.editors) { - this.deleteEditor(editor); - } - } - - get activeEditor() { - return this.editors[0]; - } - - /** - * Notifies observer when the active editor has changed. - */ - public addChangeObserver(callback: EditorGroupChangeCallback) { - this.changeObservers.push(callback); - if (this.activeEditor) { - callback(); - } - return () => { - removeFromArray(this.changeObservers, callback); - }; - } - - private notifyObservers() { - for (const observer of this.changeObservers) { - observer(); - } - } -} diff --git a/app/assets/javascripts/ui_models/editor.ts b/app/assets/javascripts/ui_models/note_controller.ts similarity index 70% rename from app/assets/javascripts/ui_models/editor.ts rename to app/assets/javascripts/ui_models/note_controller.ts index 41e2e63d6..f904cb275 100644 --- a/app/assets/javascripts/ui_models/editor.ts +++ b/app/assets/javascripts/ui_models/note_controller.ts @@ -7,7 +7,7 @@ import { } from '@standardnotes/snjs'; import { WebApplication } from './application'; -export class Editor { +export class NoteController { public note!: SNNote; private application: WebApplication; private onNoteValueChange?: (note: SNNote, source: PayloadSource) => void; @@ -28,7 +28,21 @@ export class Editor { async initialize(): Promise { if (!this.note) { - await this.createTemplateNote(this.defaultTitle, this.defaultTag); + const note = (await this.application.createTemplateItem( + ContentType.Note, + { + text: '', + title: this.defaultTitle, + references: [], + } + )) as SNNote; + if (this.defaultTag) { + const tag = this.application.findItem(this.defaultTag) as SNTag; + await this.application.addTagHierarchyToNote(note, tag); + } + this.isTemplateNote = true; + this.note = note; + this.onNoteValueChange?.(this.note, this.note.payload.source); } this.streamItems(); } @@ -67,29 +81,10 @@ export class Editor { } /** - * Reverts the editor to a blank state, removing any existing note from view, - * and creating a placeholder note. - */ - async createTemplateNote(defaultTitle?: string, noteTag?: UuidString) { - const note = (await this.application.createTemplateItem(ContentType.Note, { - text: '', - title: defaultTitle, - references: [], - })) as SNNote; - if (noteTag) { - const tag = this.application.findItem(noteTag) as SNTag; - await this.application.addTagHierarchyToNote(note, tag); - } - this.isTemplateNote = true; - this.note = note; - this.onNoteValueChange?.(this.note, this.note.payload.source); - } - - /** - * Register to be notified when the editor's note's values change + * Register to be notified when the controller's note's inner values change * (and thus a new object reference is created) */ - public setOnNoteValueChange( + public setOnNoteInnerValueChange( callback: (note: SNNote, source: PayloadSource) => void ) { this.onNoteValueChange = callback; diff --git a/app/assets/javascripts/ui_models/note_controller_group.ts b/app/assets/javascripts/ui_models/note_controller_group.ts new file mode 100644 index 000000000..a30c82898 --- /dev/null +++ b/app/assets/javascripts/ui_models/note_controller_group.ts @@ -0,0 +1,84 @@ +import { removeFromArray, UuidString } from '@standardnotes/snjs'; +import { NoteController } from './note_controller'; +import { WebApplication } from './application'; + +type NoteControllerGroupChangeCallback = () => void; + +export class NoteControllerGroup { + public noteControllers: NoteController[] = []; + private application: WebApplication; + changeObservers: NoteControllerGroupChangeCallback[] = []; + + constructor(application: WebApplication) { + this.application = application; + } + + public deinit() { + (this.application as unknown) = undefined; + for (const controller of this.noteControllers) { + this.deleteController(controller); + } + } + + async createNoteController( + noteUuid?: string, + noteTitle?: string, + noteTag?: UuidString + ) { + const controller = new NoteController( + this.application, + noteUuid, + noteTitle, + noteTag + ); + await controller.initialize(); + this.noteControllers.push(controller); + this.notifyObservers(); + } + + deleteController(controller: NoteController) { + controller.deinit(); + removeFromArray(this.noteControllers, controller); + } + + closeController(controller: NoteController) { + this.deleteController(controller); + this.notifyObservers(); + } + + closeActiveController() { + const activeController = this.activeNoteController; + if (activeController) { + this.deleteController(activeController); + } + } + + closeAllControllers() { + for (const controller of this.noteControllers) { + this.deleteController(controller); + } + } + + get activeNoteController() { + return this.noteControllers[0]; + } + + /** + * Notifies observer when the active controller has changed. + */ + public addChangeObserver(callback: NoteControllerGroupChangeCallback) { + this.changeObservers.push(callback); + if (this.activeNoteController) { + callback(); + } + return () => { + removeFromArray(this.changeObservers, callback); + }; + } + + private notifyObservers() { + for (const observer of this.changeObservers) { + observer(); + } + } +} diff --git a/app/assets/javascripts/views/editor/editor-view.pug b/app/assets/javascripts/views/editor/editor-view.pug index 3f2f73966..1c851734f 100644 --- a/app/assets/javascripts/views/editor/editor-view.pug +++ b/app/assets/javascripts/views/editor/editor-view.pug @@ -114,7 +114,7 @@ component-view.component-view( component-viewer='self.state.editorComponentViewer', ng-if='self.state.editorComponentViewer', - on-load='self.onEditorLoad', + on-load='self.onEditorComponentLoad', request-reload='self.editorComponentViewerRequestsReload' application='self.application' app-state='self.appState' diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index dd7990779..247ffab76 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -1,5 +1,5 @@ import { STRING_SAVING_WHILE_DOCUMENT_HIDDEN } from './../../strings'; -import { Editor } from '@/ui_models/editor'; +import { NoteController } from '@/ui_models/note_controller'; import { WebApplication } from '@/ui_models/application'; import { PanelPuppet, WebDirective } from '@/types'; import angular from 'angular'; @@ -93,7 +93,7 @@ function sortAlphabetically(array: SNComponent[]): SNComponent[] { export class EditorViewCtrl extends PureViewCtrl { /** Passed through template */ readonly application!: WebApplication; - readonly editor!: Editor; + readonly controller!: NoteController; private leftPanelPuppet?: PanelPuppet; private rightPanelPuppet?: PanelPuppet; @@ -101,7 +101,7 @@ export class EditorViewCtrl extends PureViewCtrl { private statusTimeout?: ng.IPromise; private lastEditorFocusEventSource?: EventSource; public editorValues: EditorValues = { title: '', text: '' }; - onEditorLoad?: () => void; + onEditorComponentLoad?: () => void; private scrollPosition = 0; private removeTrashKeyObserver?: () => void; @@ -127,7 +127,7 @@ export class EditorViewCtrl extends PureViewCtrl { this.resetScrollPosition = this.resetScrollPosition.bind(this); this.editorComponentViewerRequestsReload = this.editorComponentViewerRequestsReload.bind(this); - this.onEditorLoad = () => { + this.onEditorComponentLoad = () => { this.application.getDesktopService().redoSearch(); }; this.debounceReloadEditorComponent = debounce( @@ -148,7 +148,7 @@ export class EditorViewCtrl extends PureViewCtrl { this.removeTabObserver = undefined; this.leftPanelPuppet = undefined; this.rightPanelPuppet = undefined; - this.onEditorLoad = undefined; + this.onEditorComponentLoad = undefined; this.saveTimeout = undefined; this.statusTimeout = undefined; (this.onPanelResizeFinish as unknown) = undefined; @@ -161,14 +161,14 @@ export class EditorViewCtrl extends PureViewCtrl { } get note() { - return this.editor.note; + return this.controller.note; } $onInit() { super.$onInit(); this.registerKeyboardShortcuts(); - this.editor.setOnNoteValueChange((note, source) => { - this.onNoteChanges(note, source); + this.controller.setOnNoteInnerValueChange((note, source) => { + this.onNoteInnerChange(note, source); }); this.autorun(() => { this.setState({ @@ -184,14 +184,14 @@ export class EditorViewCtrl extends PureViewCtrl { this.reloadPreferences(); - if (this.editor.isTemplateNote) { + if (this.controller.isTemplateNote) { this.$timeout(() => { this.focusTitle(); }); } } - private onNoteChanges(note: SNNote, source: PayloadSource): void { + private onNoteInnerChange(note: SNNote, source: PayloadSource): void { if (note.uuid !== this.note.uuid) { throw Error('Editor received changes for non-current note'); } @@ -423,8 +423,8 @@ export class EditorViewCtrl extends PureViewCtrl { this.note ); /** Editors cannot interact with template notes so the note must be inserted */ - if (newEditor && this.editor.isTemplateNote) { - await this.editor.insertTemplatedNote(); + if (newEditor && this.controller.isTemplateNote) { + await this.controller.insertTemplatedNote(); this.associateComponentWithCurrentNote(newEditor); } const currentComponentViewer = this.state.editorComponentViewer; @@ -479,8 +479,8 @@ export class EditorViewCtrl extends PureViewCtrl { const transactions: TransactionalMutation[] = []; this.setMenuState('showEditorMenu', false); - if (this.appState.getActiveEditor()?.isTemplateNote) { - await this.appState.getActiveEditor().insertTemplatedNote(); + if (this.appState.getActiveNoteController()?.isTemplateNote) { + await this.appState.getActiveNoteController().insertTemplatedNote(); } if (this.note.locked) { this.application.alertService.alert(STRING_EDIT_LOCKED_ATTEMPT); @@ -566,7 +566,7 @@ export class EditorViewCtrl extends PureViewCtrl { ) { const title = editorValues.title; const text = editorValues.text; - const isTemplate = this.editor.isTemplateNote; + const isTemplate = this.controller.isTemplateNote; if (document.hidden) { this.application.alertService.alert(STRING_SAVING_WHILE_DOCUMENT_HIDDEN); return; @@ -576,7 +576,7 @@ export class EditorViewCtrl extends PureViewCtrl { return; } if (isTemplate) { - await this.editor.insertTemplatedNote(); + await this.controller.insertTemplatedNote(); } if (!this.application.findItem(note.uuid)) { this.application.alertService.alert(STRING_INVALID_NOTE); @@ -614,7 +614,7 @@ export class EditorViewCtrl extends PureViewCtrl { this.saveTimeout = this.$timeout(() => { this.application.sync(); if (closeAfterSync) { - this.appState.closeEditor(this.editor); + this.appState.closeNoteController(this.controller); } }, syncDebouceMs); } @@ -719,7 +719,7 @@ export class EditorViewCtrl extends PureViewCtrl { } async deleteNote(permanently: boolean) { - if (this.editor.isTemplateNote) { + if (this.controller.isTemplateNote) { this.application.alertService.alert(STRING_DELETE_PLACEHOLDER_ATTEMPT); return; } @@ -1044,7 +1044,7 @@ export class EditorView extends WebDirective { super(); this.restrict = 'E'; this.scope = { - editor: '=', + controller: '=', application: '=', }; this.template = template; diff --git a/app/assets/javascripts/views/editor_group/editor-group-view.pug b/app/assets/javascripts/views/editor_group/editor-group-view.pug index 2947a1dbe..de3ed6773 100644 --- a/app/assets/javascripts/views/editor_group/editor-group-view.pug +++ b/app/assets/javascripts/views/editor_group/editor-group-view.pug @@ -6,9 +6,9 @@ ) .flex-grow.h-full( ng-if='!self.state.showMultipleSelectedNotes' - ng-repeat='editor in self.editors' + ng-repeat='controller in self.controllers' ) editor-view( application='self.application' - editor='editor' + controller='controller' ) diff --git a/app/assets/javascripts/views/editor_group/editor_group_view.ts b/app/assets/javascripts/views/editor_group/editor_group_view.ts index df7ded8e6..4b056b121 100644 --- a/app/assets/javascripts/views/editor_group/editor_group_view.ts +++ b/app/assets/javascripts/views/editor_group/editor_group_view.ts @@ -1,29 +1,31 @@ import { WebDirective } from './../../types'; import template from './editor-group-view.pug'; -import { Editor } from '@/ui_models/editor'; +import { NoteController } from '@/ui_models/note_controller'; import { PureViewCtrl } from '../abstract/pure_view_ctrl'; -class EditorGroupViewCtrl extends PureViewCtrl { - - public editors: Editor[] = [] +class EditorGroupViewCtrl extends PureViewCtrl< + unknown, + { + showMultipleSelectedNotes: boolean; + } +> { + public controllers: NoteController[] = []; /* @ngInject */ - constructor($timeout: ng.ITimeoutService,) { + constructor($timeout: ng.ITimeoutService) { super($timeout); this.state = { - showMultipleSelectedNotes: false + showMultipleSelectedNotes: false, }; } $onInit() { - this.application.editorGroup.addChangeObserver(() => { - this.editors = this.application.editorGroup.editors; + this.application.noteControllerGroup.addChangeObserver(() => { + this.controllers = this.application.noteControllerGroup.noteControllers; }); this.autorun(() => { this.setState({ - showMultipleSelectedNotes: this.appState.notes.selectedNotesCount > 1 + showMultipleSelectedNotes: this.appState.notes.selectedNotesCount > 1, }); }); } @@ -37,7 +39,7 @@ export class EditorGroupView extends WebDirective { this.controllerAs = 'self'; this.bindToController = true; this.scope = { - application: '=' + application: '=', }; } } From 0eeb9b7da11b98c89d785c97040975fd76c5b959 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 27 Dec 2021 22:56:21 -0600 Subject: [PATCH 7/9] refactor: rename note controller to note view controller --- app/assets/javascripts/app.ts | 8 ++--- .../ui_models/app_state/app_state.ts | 12 +++---- .../ui_models/app_state/notes_state.ts | 8 ++--- .../javascripts/ui_models/application.ts | 6 ++-- .../views/application/application-view.pug | 2 +- app/assets/javascripts/views/index.ts | 4 +-- .../note-group-view.pug} | 2 +- .../note_group_view/note_group_controller.ts} | 34 +++++++++---------- .../note_group_view.ts} | 12 +++---- .../note-view.pug} | 0 .../note_view.test.ts} | 6 ++-- .../editor_view.ts => note_view/note_view.ts} | 12 +++---- .../note_view/note_view_controller.ts} | 4 +-- 13 files changed, 55 insertions(+), 55 deletions(-) rename app/assets/javascripts/views/{editor_group/editor-group-view.pug => note_group_view/note-group-view.pug} (95%) rename app/assets/javascripts/{ui_models/note_controller_group.ts => views/note_group_view/note_group_controller.ts} (65%) rename app/assets/javascripts/views/{editor_group/editor_group_view.ts => note_group_view/note_group_view.ts} (72%) rename app/assets/javascripts/views/{editor/editor-view.pug => note_view/note-view.pug} (100%) rename app/assets/javascripts/views/{editor/editor_view.test.ts => note_view/note_view.test.ts} (97%) rename app/assets/javascripts/views/{editor/editor_view.ts => note_view/note_view.ts} (99%) rename app/assets/javascripts/{ui_models/note_controller.ts => views/note_view/note_view_controller.ts} (96%) diff --git a/app/assets/javascripts/app.ts b/app/assets/javascripts/app.ts index 05b5dbd3d..039f62df9 100644 --- a/app/assets/javascripts/app.ts +++ b/app/assets/javascripts/app.ts @@ -30,8 +30,8 @@ import { AccountSwitcher } from './views/account_switcher/account_switcher'; import { ApplicationGroupView, ApplicationView, - EditorGroupView, - EditorView, + NoteGroupViewDirective, + NoteViewDirective, TagsView, FooterView, ChallengeModal, @@ -141,8 +141,8 @@ const startApplication: StartApplication = async function startApplication( .module('app') .directive('applicationGroupView', () => new ApplicationGroupView()) .directive('applicationView', () => new ApplicationView()) - .directive('editorGroupView', () => new EditorGroupView()) - .directive('editorView', () => new EditorView()) + .directive('noteGroupView', () => new NoteGroupViewDirective()) + .directive('noteView', () => new NoteViewDirective()) .directive('tagsView', () => new TagsView()) .directive('footerView', () => new FooterView()); diff --git a/app/assets/javascripts/ui_models/app_state/app_state.ts b/app/assets/javascripts/ui_models/app_state/app_state.ts index e413c2922..642d9f8c0 100644 --- a/app/assets/javascripts/ui_models/app_state/app_state.ts +++ b/app/assets/javascripts/ui_models/app_state/app_state.ts @@ -2,7 +2,7 @@ import { Bridge } from '@/services/bridge'; import { storage, StorageKey } from '@/services/localStorage'; import { WebApplication } from '@/ui_models/application'; import { AccountMenuState } from '@/ui_models/app_state/account_menu_state'; -import { NoteController } from '@/ui_models/note_controller'; +import { NoteViewController } from '@/views/note_view/note_view_controller'; import { isDesktopApplication } from '@/utils'; import { ApplicationEvent, @@ -236,7 +236,7 @@ export class AppState { : this.selectedTag.uuid : undefined; - await this.application.noteControllerGroup.createNoteController( + await this.application.noteControllerGroup.createNoteView( undefined, title, activeTagUuid @@ -251,16 +251,16 @@ export class AppState { return this.application.noteControllerGroup.noteControllers; } - closeNoteController(controller: NoteController) { - this.application.noteControllerGroup.closeController(controller); + closeNoteController(controller: NoteViewController) { + this.application.noteControllerGroup.closeNoteView(controller); } closeActiveNoteController() { - this.application.noteControllerGroup.closeActiveController(); + this.application.noteControllerGroup.closeActiveNoteView(); } closeAllNoteControllers() { - this.application.noteControllerGroup.closeAllControllers(); + this.application.noteControllerGroup.closeAllNoteViews(); } noteControllerForNote(note: SNNote) { diff --git a/app/assets/javascripts/ui_models/app_state/notes_state.ts b/app/assets/javascripts/ui_models/app_state/notes_state.ts index 05859a376..44dda28e1 100644 --- a/app/assets/javascripts/ui_models/app_state/notes_state.ts +++ b/app/assets/javascripts/ui_models/app_state/notes_state.ts @@ -17,7 +17,7 @@ import { runInAction, } from 'mobx'; import { WebApplication } from '../application'; -import { NoteController } from '../note_controller'; +import { NoteViewController } from '@/views/note_view/note_view_controller'; import { AppState } from './app_state'; export class NotesState { @@ -68,7 +68,7 @@ export class NotesState { ); } - get activeNoteController(): NoteController | undefined { + get activeNoteController(): NoteViewController | undefined { return this.application.noteControllerGroup.noteControllers[0]; } @@ -168,10 +168,10 @@ export class NotesState { } if (this.activeNoteController) { - this.application.noteControllerGroup.closeActiveController(); + this.application.noteControllerGroup.closeActiveNoteView(); } - await this.application.noteControllerGroup.createNoteController(noteUuid); + await this.application.noteControllerGroup.createNoteView(noteUuid); this.appState.noteTags.reloadTags(); await this.onActiveEditorChanged(); diff --git a/app/assets/javascripts/ui_models/application.ts b/app/assets/javascripts/ui_models/application.ts index 5a9ac004d..d574a938b 100644 --- a/app/assets/javascripts/ui_models/application.ts +++ b/app/assets/javascripts/ui_models/application.ts @@ -10,7 +10,7 @@ import { StatusManager } from '@/services/statusManager'; import { ThemeManager } from '@/services/themeManager'; import { PasswordWizardScope, PasswordWizardType } from '@/types'; import { AppState } from '@/ui_models/app_state'; -import { NoteControllerGroup } from '@/ui_models/note_controller_group'; +import { NoteGroupController } from '@/views/note_group_view/note_group_controller'; import { AppVersion } from '@/version'; import { WebDeviceInterface } from '@/web_device_interface'; import { @@ -36,7 +36,7 @@ export class WebApplication extends SNApplication { private scope?: angular.IScope; private webServices!: WebServices; private currentAuthenticationElement?: angular.IRootElementService; - public noteControllerGroup: NoteControllerGroup; + public noteControllerGroup: NoteGroupController; /* @ngInject */ constructor( @@ -66,7 +66,7 @@ export class WebApplication extends SNApplication { this.$compile = $compile; this.scope = scope; deviceInterface.setApplication(this); - this.noteControllerGroup = new NoteControllerGroup(this); + this.noteControllerGroup = new NoteGroupController(this); this.presentPermissionsDialog = this.presentPermissionsDialog.bind(this); } diff --git a/app/assets/javascripts/views/application/application-view.pug b/app/assets/javascripts/views/application/application-view.pug index e39519b6c..01630f2b5 100644 --- a/app/assets/javascripts/views/application/application-view.pug +++ b/app/assets/javascripts/views/application/application-view.pug @@ -10,7 +10,7 @@ application='self.application' app-state='self.appState' ) - editor-group-view.flex-grow(application='self.application') + note-group-view.flex-grow(application='self.application') footer-view( ng-if='!self.state.needsUnlock && self.state.launched' diff --git a/app/assets/javascripts/views/index.ts b/app/assets/javascripts/views/index.ts index a68bf862d..82223ae4c 100644 --- a/app/assets/javascripts/views/index.ts +++ b/app/assets/javascripts/views/index.ts @@ -1,8 +1,8 @@ export { PureViewCtrl } from './abstract/pure_view_ctrl'; export { ApplicationGroupView } from './application_group/application_group_view'; export { ApplicationView } from './application/application_view'; -export { EditorGroupView } from './editor_group/editor_group_view'; -export { EditorView } from './editor/editor_view'; +export { NoteGroupViewDirective } from './note_group_view/note_group_view'; +export { NoteViewDirective } from './note_view/note_view'; export { FooterView } from './footer/footer_view'; export { TagsView } from './tags/tags_view'; export { ChallengeModal } from './challenge_modal/challenge_modal'; diff --git a/app/assets/javascripts/views/editor_group/editor-group-view.pug b/app/assets/javascripts/views/note_group_view/note-group-view.pug similarity index 95% rename from app/assets/javascripts/views/editor_group/editor-group-view.pug rename to app/assets/javascripts/views/note_group_view/note-group-view.pug index de3ed6773..4baafa105 100644 --- a/app/assets/javascripts/views/editor_group/editor-group-view.pug +++ b/app/assets/javascripts/views/note_group_view/note-group-view.pug @@ -8,7 +8,7 @@ ng-if='!self.state.showMultipleSelectedNotes' ng-repeat='controller in self.controllers' ) - editor-view( + note-view( application='self.application' controller='controller' ) diff --git a/app/assets/javascripts/ui_models/note_controller_group.ts b/app/assets/javascripts/views/note_group_view/note_group_controller.ts similarity index 65% rename from app/assets/javascripts/ui_models/note_controller_group.ts rename to app/assets/javascripts/views/note_group_view/note_group_controller.ts index a30c82898..c625fc47c 100644 --- a/app/assets/javascripts/ui_models/note_controller_group.ts +++ b/app/assets/javascripts/views/note_group_view/note_group_controller.ts @@ -1,11 +1,11 @@ import { removeFromArray, UuidString } from '@standardnotes/snjs'; -import { NoteController } from './note_controller'; -import { WebApplication } from './application'; +import { NoteViewController } from '@/views/note_view/note_view_controller'; +import { WebApplication } from '@/ui_models/application'; type NoteControllerGroupChangeCallback = () => void; -export class NoteControllerGroup { - public noteControllers: NoteController[] = []; +export class NoteGroupController { + public noteControllers: NoteViewController[] = []; private application: WebApplication; changeObservers: NoteControllerGroupChangeCallback[] = []; @@ -16,16 +16,16 @@ export class NoteControllerGroup { public deinit() { (this.application as unknown) = undefined; for (const controller of this.noteControllers) { - this.deleteController(controller); + this.deleteNoteView(controller); } } - async createNoteController( + async createNoteView( noteUuid?: string, noteTitle?: string, noteTag?: UuidString ) { - const controller = new NoteController( + const controller = new NoteViewController( this.application, noteUuid, noteTitle, @@ -36,30 +36,30 @@ export class NoteControllerGroup { this.notifyObservers(); } - deleteController(controller: NoteController) { + deleteNoteView(controller: NoteViewController) { controller.deinit(); removeFromArray(this.noteControllers, controller); } - closeController(controller: NoteController) { - this.deleteController(controller); + closeNoteView(controller: NoteViewController) { + this.deleteNoteView(controller); this.notifyObservers(); } - closeActiveController() { - const activeController = this.activeNoteController; + closeActiveNoteView() { + const activeController = this.activeNoteViewController; if (activeController) { - this.deleteController(activeController); + this.deleteNoteView(activeController); } } - closeAllControllers() { + closeAllNoteViews() { for (const controller of this.noteControllers) { - this.deleteController(controller); + this.deleteNoteView(controller); } } - get activeNoteController() { + get activeNoteViewController() { return this.noteControllers[0]; } @@ -68,7 +68,7 @@ export class NoteControllerGroup { */ public addChangeObserver(callback: NoteControllerGroupChangeCallback) { this.changeObservers.push(callback); - if (this.activeNoteController) { + if (this.activeNoteViewController) { callback(); } return () => { diff --git a/app/assets/javascripts/views/editor_group/editor_group_view.ts b/app/assets/javascripts/views/note_group_view/note_group_view.ts similarity index 72% rename from app/assets/javascripts/views/editor_group/editor_group_view.ts rename to app/assets/javascripts/views/note_group_view/note_group_view.ts index 4b056b121..8d598d1aa 100644 --- a/app/assets/javascripts/views/editor_group/editor_group_view.ts +++ b/app/assets/javascripts/views/note_group_view/note_group_view.ts @@ -1,15 +1,15 @@ import { WebDirective } from './../../types'; -import template from './editor-group-view.pug'; -import { NoteController } from '@/ui_models/note_controller'; +import template from './note-group-view.pug'; +import { NoteViewController } from '@/views/note_view/note_view_controller'; import { PureViewCtrl } from '../abstract/pure_view_ctrl'; -class EditorGroupViewCtrl extends PureViewCtrl< +class NoteGroupView extends PureViewCtrl< unknown, { showMultipleSelectedNotes: boolean; } > { - public controllers: NoteController[] = []; + public controllers: NoteViewController[] = []; /* @ngInject */ constructor($timeout: ng.ITimeoutService) { @@ -31,11 +31,11 @@ class EditorGroupViewCtrl extends PureViewCtrl< } } -export class EditorGroupView extends WebDirective { +export class NoteGroupViewDirective extends WebDirective { constructor() { super(); this.template = template; - this.controller = EditorGroupViewCtrl; + this.controller = NoteGroupView; this.controllerAs = 'self'; this.bindToController = true; this.scope = { diff --git a/app/assets/javascripts/views/editor/editor-view.pug b/app/assets/javascripts/views/note_view/note-view.pug similarity index 100% rename from app/assets/javascripts/views/editor/editor-view.pug rename to app/assets/javascripts/views/note_view/note-view.pug diff --git a/app/assets/javascripts/views/editor/editor_view.test.ts b/app/assets/javascripts/views/note_view/note_view.test.ts similarity index 97% rename from app/assets/javascripts/views/editor/editor_view.test.ts rename to app/assets/javascripts/views/note_view/note_view.test.ts index d70a3c9d0..c93066854 100644 --- a/app/assets/javascripts/views/editor/editor_view.test.ts +++ b/app/assets/javascripts/views/note_view/note_view.test.ts @@ -2,19 +2,19 @@ * @jest-environment jsdom */ -import { EditorViewCtrl } from '@Views/editor/editor_view'; +import { NoteView } from '@Views/note_view/note_view'; import { ApplicationEvent, ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction, } from '@standardnotes/snjs/'; describe('editor-view', () => { - let ctrl: EditorViewCtrl; + let ctrl: NoteView; let setShowProtectedWarningSpy: jest.SpyInstance; beforeEach(() => { const $timeout = {} as jest.Mocked; - ctrl = new EditorViewCtrl($timeout); + ctrl = new NoteView($timeout); setShowProtectedWarningSpy = jest.spyOn(ctrl, 'setShowProtectedOverlay'); diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/note_view/note_view.ts similarity index 99% rename from app/assets/javascripts/views/editor/editor_view.ts rename to app/assets/javascripts/views/note_view/note_view.ts index 247ffab76..cd3857605 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/note_view/note_view.ts @@ -1,5 +1,5 @@ import { STRING_SAVING_WHILE_DOCUMENT_HIDDEN } from './../../strings'; -import { NoteController } from '@/ui_models/note_controller'; +import { NoteViewController } from '@/views/note_view/note_view_controller'; import { WebApplication } from '@/ui_models/application'; import { PanelPuppet, WebDirective } from '@/types'; import angular from 'angular'; @@ -23,7 +23,7 @@ import { } from '@standardnotes/snjs'; import { debounce, isDesktopApplication } from '@/utils'; import { KeyboardModifier, KeyboardKey } from '@/services/ioService'; -import template from './editor-view.pug'; +import template from './note-view.pug'; import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl'; import { EventSource } from '@/ui_models/app_state'; import { @@ -90,10 +90,10 @@ function sortAlphabetically(array: SNComponent[]): SNComponent[] { ); } -export class EditorViewCtrl extends PureViewCtrl { +export class NoteView extends PureViewCtrl { /** Passed through template */ readonly application!: WebApplication; - readonly controller!: NoteController; + readonly controller!: NoteViewController; private leftPanelPuppet?: PanelPuppet; private rightPanelPuppet?: PanelPuppet; @@ -1039,7 +1039,7 @@ export class EditorViewCtrl extends PureViewCtrl { } } -export class EditorView extends WebDirective { +export class NoteViewDirective extends WebDirective { constructor() { super(); this.restrict = 'E'; @@ -1049,7 +1049,7 @@ export class EditorView extends WebDirective { }; this.template = template; this.replace = true; - this.controller = EditorViewCtrl; + this.controller = NoteView; this.controllerAs = 'self'; this.bindToController = true; } diff --git a/app/assets/javascripts/ui_models/note_controller.ts b/app/assets/javascripts/views/note_view/note_view_controller.ts similarity index 96% rename from app/assets/javascripts/ui_models/note_controller.ts rename to app/assets/javascripts/views/note_view/note_view_controller.ts index f904cb275..5b6a81d14 100644 --- a/app/assets/javascripts/ui_models/note_controller.ts +++ b/app/assets/javascripts/views/note_view/note_view_controller.ts @@ -5,9 +5,9 @@ import { UuidString, SNTag, } from '@standardnotes/snjs'; -import { WebApplication } from './application'; +import { WebApplication } from '@/ui_models/application'; -export class NoteController { +export class NoteViewController { public note!: SNNote; private application: WebApplication; private onNoteValueChange?: (note: SNNote, source: PayloadSource) => void; From 4149b03312eec5179bd8cf353832767676127285 Mon Sep 17 00:00:00 2001 From: Mo Date: Tue, 28 Dec 2021 10:49:28 -0600 Subject: [PATCH 8/9] chore(deps): snjs + features --- package.json | 4 ++-- yarn.lock | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 027066f3f..a4999bca7 100644 --- a/package.json +++ b/package.json @@ -84,10 +84,10 @@ "@reach/checkbox": "^0.16.0", "@reach/dialog": "^0.16.2", "@reach/listbox": "^0.16.2", - "@standardnotes/features": "1.10.2", + "@standardnotes/features": "1.15.1", "@reach/tooltip": "^0.16.2", "@standardnotes/sncrypto-web": "1.5.3", - "@standardnotes/snjs": "2.29.0", + "@standardnotes/snjs": "2.30.0", "mobx": "^6.3.5", "mobx-react-lite": "^3.2.2", "preact": "^10.5.15", diff --git a/yarn.lock b/yarn.lock index a86fd2d27..5a8cea5e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2623,14 +2623,6 @@ dependencies: "@standardnotes/auth" "^3.8.1" -"@standardnotes/features@1.10.2": - version "1.10.2" - resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.10.2.tgz#a0783f66c00e21cb7692edc0cea95ec25a0253a5" - integrity sha512-Zh6EMjli4mL6jlXEhMyU3qYIKFJj5kuhbxtHXiErUGIDy+s1hHY+THFFO53Jdga2+8wgcATWlmSBY7dieVA8uA== - dependencies: - "@standardnotes/auth" "3.8.3" - "@standardnotes/common" "^1.2.1" - "@standardnotes/features@1.11.0": version "1.11.0" resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.11.0.tgz#66e960a20358c5f58b6be4e19226b34df6f4efbf" @@ -2639,6 +2631,14 @@ "@standardnotes/auth" "3.8.3" "@standardnotes/common" "^1.2.1" +"@standardnotes/features@1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.15.1.tgz#3880d73fb32ab952359e70fb313abfdf14023c7d" + integrity sha512-QurBvYwfNrcAKLwE7Z/1EsFpZ6Vuwp8E9O7jlMlzf0GyMXY/djCooeXjmoCWed+B/qJ4sdDdtptGyMsjKVeJCw== + dependencies: + "@standardnotes/auth" "3.8.3" + "@standardnotes/common" "1.2.1" + "@standardnotes/settings@^1.8.0": version "1.8.0" resolved "https://registry.yarnpkg.com/@standardnotes/settings/-/settings-1.8.0.tgz#d7bd1f35c3b500d12ba73f5f385b1019baae3efc" @@ -2658,10 +2658,10 @@ buffer "^6.0.3" libsodium-wrappers "^0.7.9" -"@standardnotes/snjs@2.29.0": - version "2.29.0" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.29.0.tgz#6c7c6ccd983df4a1a5e2063647eb731304002fd9" - integrity sha512-Y+GpNiFyJtVr2W3nVbC2zljtXpBlqe3cB4+R1REE0V4hnQBaq/HE6PaUd80TnFj99Kl8lowyH/o4bNV3+CjGgg== +"@standardnotes/snjs@2.30.0": + version "2.30.0" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.30.0.tgz#12abda65e8069273347bbf6786d6a99203260023" + integrity sha512-0s7NYtO8edvY3/MNwx/Ic+fIDXiSnaVhdBWlaIOreVHwUl15LkHyN8mptR8QLtHOjOhvaguew+KCvmXXmkNjTA== dependencies: "@standardnotes/auth" "3.8.1" "@standardnotes/common" "1.2.1" From 0a8286ffec08a11aeac148e55430bf2b830e221b Mon Sep 17 00:00:00 2001 From: Mo Date: Tue, 28 Dec 2021 10:51:52 -0600 Subject: [PATCH 9/9] chore: bump version to 3.9.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4999bca7..de6783cdd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "standard-notes-web", - "version": "3.9.10", + "version": "3.9.11", "license": "AGPL-3.0-or-later", "repository": { "type": "git",