diff --git a/.env.sample b/.env.sample index c7ad4a0b306..5033e80ba53 100644 --- a/.env.sample +++ b/.env.sample @@ -15,6 +15,7 @@ SF_DEFAULT_SERVER=http://localhost:3000 DEV_DEFAULT_SYNC_SERVER=https://api.standardnotes.com DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html ENABLE_UNFINISHED_FEATURES=false +DEV_WEBSOCKET_URL=wss://sockets-dev.standardnotes.com # NewRelic (Optional) NEW_RELIC_ENABLED=false diff --git a/app/assets/javascripts/app.ts b/app/assets/javascripts/app.ts index d354335b71f..e7470bbe09c 100644 --- a/app/assets/javascripts/app.ts +++ b/app/assets/javascripts/app.ts @@ -91,6 +91,7 @@ function reloadHiddenFirefoxTab(): boolean { const startApplication: StartApplication = async function startApplication( defaultSyncServerHost: string, bridge: Bridge, + webSocketUrl: string, ) { if (reloadHiddenFirefoxTab()) { return; @@ -107,7 +108,8 @@ const startApplication: StartApplication = async function startApplication( .config(configRoutes) .constant('bridge', bridge) .constant('defaultSyncServerHost', defaultSyncServerHost) - .constant('appVersion', bridge.appVersion); + .constant('appVersion', bridge.appVersion) + .constant('webSocketUrl', webSocketUrl); // Controllers angular @@ -193,6 +195,7 @@ if (__WEB__) { startApplication( (window as any)._default_sync_server, new BrowserBridge(__VERSION__), + (window as any)._websocket_url, ); } else { (window as any).startApplication = startApplication; diff --git a/app/assets/javascripts/startApplication.ts b/app/assets/javascripts/startApplication.ts index b7fdf25807c..a3f5b16681d 100644 --- a/app/assets/javascripts/startApplication.ts +++ b/app/assets/javascripts/startApplication.ts @@ -3,4 +3,5 @@ import { Bridge } from "./services/bridge"; export type StartApplication = ( defaultSyncServerHost: string, bridge: Bridge, + webSocketUrl: string, ) => Promise<void>; 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 04fa7ff4b46..0a897f55a6a 100644 --- a/app/assets/javascripts/ui_models/app_state/app_state.ts +++ b/app/assets/javascripts/ui_models/app_state/app_state.ts @@ -246,11 +246,16 @@ export class AppState { } if (note.deleted) { this.closeEditor(editor); - } else if (note.trashed && !this.selectedTag?.isTrashTag) { + } else if ( + note.trashed && + !this.selectedTag?.isTrashTag && + !this.searchOptions.includeTrashed + ) { this.closeEditor(editor); } else if ( note.archived && !this.selectedTag?.isArchiveTag && + !this.searchOptions.includeArchived && !this.application.getPreference(PrefKey.NotesShowArchived, false) ) { this.closeEditor(editor); diff --git a/app/assets/javascripts/ui_models/application_group.ts b/app/assets/javascripts/ui_models/application_group.ts index 0fd5252deda..795e7530a44 100644 --- a/app/assets/javascripts/ui_models/application_group.ts +++ b/app/assets/javascripts/ui_models/application_group.ts @@ -29,6 +29,7 @@ export class ApplicationGroup extends SNApplicationGroup { $timeout: ng.ITimeoutService, private defaultSyncServerHost: string, private bridge: Bridge, + private webSocketUrl: string ) { super(new WebDeviceInterface($timeout, bridge)); this.$compile = $compile; diff --git a/app/assets/javascripts/views/notes/notes_view.ts b/app/assets/javascripts/views/notes/notes_view.ts index 5ad8a32c849..f1babb53b21 100644 --- a/app/assets/javascripts/views/notes/notes_view.ts +++ b/app/assets/javascripts/views/notes/notes_view.ts @@ -255,7 +255,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> { if (selectedTag.isSmartTag && !selectedTag.isAllTag) { return; } - return this.createNewNote(); + return this.createNewNote(false); } streamNotesAndTags() { @@ -277,7 +277,11 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> { if (this.application.getAppState().notes.selectedNotesCount < 2) { if (activeNote) { const discarded = activeNote.deleted || activeNote.trashed; - if (discarded && !this.appState?.selectedTag?.isTrashTag) { + if ( + discarded && + !this.appState?.selectedTag?.isTrashTag && + !this.appState?.searchOptions.includeTrashed + ) { this.selectNextOrCreateNew(); } else if (!this.state.selectedNotes[activeNote.uuid]) { this.selectNote(activeNote); @@ -354,7 +358,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> { await this.appState.notes.selectNote(note.uuid, userTriggered); } - async createNewNote() { + async createNewNote(focusNewNote = true) { this.appState.notes.unselectNotes(); let title = `Note ${this.state.notes.length + 1}`; if (this.isFiltering()) { @@ -365,7 +369,9 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> { await this.reloadNotes(); await this.appState.noteTags.reloadTags(); const noteTitleEditorElement = document.getElementById('note-title-editor'); - noteTitleEditorElement?.focus(); + if (focusNewNote) { + noteTitleEditorElement?.focus(); + } } async handleTagChange(tag: SNTag) { diff --git a/app/views/application/app.html.erb b/app/views/application/app.html.erb index 0cd8b0d88b7..2bc9dc47089 100644 --- a/app/views/application/app.html.erb +++ b/app/views/application/app.html.erb @@ -34,6 +34,7 @@ window._batch_manager_location = "<%= ENV['BATCH_MANAGER_LOCATION'] %>"; window._bugsnag_api_key = "<%= ENV['BUGSNAG_API_KEY'] %>"; window._enable_unfinished_features = "<%= ENV['ENABLE_UNFINISHED_FEATURES'] %>" === 'true'; + window._websocket_url = "<%= ENV['WEBSOCKET_URL'] %>"; </script> <% if Rails.env.development? %> diff --git a/index.html b/index.html index ad4ed41e84a..691b2da488f 100644 --- a/index.html +++ b/index.html @@ -33,12 +33,14 @@ data-extensions-manager-location="<%= env.DEV_EXTENSIONS_MANAGER_LOCATION %>" data-bugsnag-api-key="<%= env.DEV_BUGSNAG_API_KEY %>" data-enable-unfinished-features="<%= env.ENABLE_UNFINISHED_FEATURES %>" + data-web-socket-url="<%= env.DEV_WEBSOCKET_URL %>" > <script> window._default_sync_server = document.body.dataset.defaultSyncServer || "https://api.standardnotes.com"; window._extensions_manager_location = document.body.dataset.extensionsManagerLocation || "public/extensions/extensions-manager/dist/index.html"; window._bugsnag_api_key = document.body.dataset.bugsnagApiKey; window._enable_unfinished_features = document.body.dataset.enableUnfinishedFeatures === 'true'; + window._websocket_url = document.body.dataset.webSocketUrl; </script> <application-group-view /> </body> diff --git a/package.json b/package.json index 4da575b8b7c..6c9f8762dc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "standard-notes-web", - "version": "3.8.17", + "version": "3.8.18", "license": "AGPL-3.0-or-later", "repository": { "type": "git", @@ -71,7 +71,7 @@ "@reach/checkbox": "^0.13.2", "@reach/dialog": "^0.13.0", "@standardnotes/sncrypto-web": "1.2.10", - "@standardnotes/snjs": "2.7.18", + "@standardnotes/snjs": "2.7.21", "mobx": "^6.1.6", "mobx-react-lite": "^3.2.0", "preact": "^10.5.12" diff --git a/yarn.lock b/yarn.lock index eda2a81fff3..bf79c098b74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2011,10 +2011,10 @@ prop-types "^15.7.2" tslib "^2.1.0" -"@standardnotes/auth@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@standardnotes/auth/-/auth-2.0.0.tgz#93f633fd40855f87843f911109e92b29dcbc5a04" - integrity sha512-B2NznCm3pzwBvBU/YQfuDrtlEbLO3hNH3QrqSwK2dFwUGAnl5UQPC9FKFWYgly05rWevwMY3IUmiZRzUEVlKsQ== +"@standardnotes/auth@3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@standardnotes/auth/-/auth-3.1.1.tgz#834701c2e14d31eb204bff90457fa05e9183464a" + integrity sha512-E9zDYZ1gJkVZBEzd7a1L2haQ4GYeH1lUrY87UmDH1AMYUHW+c0SqZ71af1fBNqGzrx3EZSXk+Qzr7RyOa6N1Mw== "@standardnotes/sncrypto-common@^1.2.7", "@standardnotes/sncrypto-common@^1.2.9": version "1.2.9" @@ -2029,12 +2029,12 @@ "@standardnotes/sncrypto-common" "^1.2.7" libsodium-wrappers "^0.7.8" -"@standardnotes/snjs@2.7.18": - version "2.7.18" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.18.tgz#90dd33576176da53714438e0819eef180c221381" - integrity sha512-fXv91FhsxLRMK9KR1LLNzG/k9vdnMqrqMwQrfRECDqJRG2iZvlvVqzgWKBCYtCvLRHSRnFmt0xPKA2yuTkZqpA== +"@standardnotes/snjs@2.7.21": + version "2.7.21" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.21.tgz#db451e5facaf5fa41fa509eb1f304723929c3541" + integrity sha512-GhkGk1LJmD494COZkSOgyHaUnGnLWNLlSuCZMTwbw3dgkN5PjobbRhfDvEZaLqjwok+h9nkiQt3hugQ3h6Cy5w== dependencies: - "@standardnotes/auth" "^2.0.0" + "@standardnotes/auth" "3.1.1" "@standardnotes/sncrypto-common" "^1.2.9" "@svgr/babel-plugin-add-jsx-attribute@^5.4.0":