refactor: improve device interface types (#996)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { Bridge } from '@/Services/Bridge'
|
||||
import { storage, StorageKey } from '@/Services/LocalStorage'
|
||||
import { WebApplication, WebAppEvent } from '@/UIModels/Application'
|
||||
import { AccountMenuState } from '@/UIModels/AppState/AccountMenuState'
|
||||
@@ -32,6 +31,7 @@ import { SearchOptionsState } from './SearchOptionsState'
|
||||
import { SubscriptionState } from './SubscriptionState'
|
||||
import { SyncState } from './SyncState'
|
||||
import { TagsState } from './TagsState'
|
||||
import { WebOrDesktopDevice } from '@/Device/WebOrDesktopDevice'
|
||||
|
||||
export enum AppStateEvent {
|
||||
TagChanged,
|
||||
@@ -91,7 +91,7 @@ export class AppState {
|
||||
|
||||
private readonly tagChangedDisposer: IReactionDisposer
|
||||
|
||||
constructor(application: WebApplication, private bridge: Bridge) {
|
||||
constructor(application: WebApplication, private device: WebOrDesktopDevice) {
|
||||
this.application = application
|
||||
this.notes = new NotesState(
|
||||
application,
|
||||
@@ -120,7 +120,7 @@ export class AppState {
|
||||
}
|
||||
this.registerVisibilityObservers()
|
||||
|
||||
if (this.bridge.appVersion.includes('-beta')) {
|
||||
if (this.device.appVersion.includes('-beta')) {
|
||||
this.showBetaWarning = storage.get(StorageKey.ShowBetaWarning) ?? true
|
||||
} else {
|
||||
this.showBetaWarning = false
|
||||
@@ -198,7 +198,7 @@ export class AppState {
|
||||
}
|
||||
|
||||
public get version(): string {
|
||||
return this.bridge.appVersion
|
||||
return this.device.appVersion
|
||||
}
|
||||
|
||||
async openNewNote(title?: string) {
|
||||
|
||||
@@ -379,8 +379,9 @@ export class NotesViewState {
|
||||
paginate = () => {
|
||||
this.notesToDisplay += this.pageSize
|
||||
this.reloadNotes()
|
||||
|
||||
if (this.searchSubmitted) {
|
||||
this.application.getDesktopService().searchText(this.noteFilterText)
|
||||
this.application.getDesktopService()?.searchText(this.noteFilterText)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,8 +483,9 @@ export class NotesViewState {
|
||||
})
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
if (this.isFiltering) {
|
||||
this.application.getDesktopService().searchText(this.noteFilterText)
|
||||
this.application.getDesktopService()?.searchText(this.noteFilterText)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,9 +498,13 @@ export class NotesViewState {
|
||||
|
||||
handleTagChange = () => {
|
||||
this.resetScrollPosition()
|
||||
|
||||
this.setShowDisplayOptionsMenu(false)
|
||||
|
||||
this.setNoteFilterText('')
|
||||
this.application.getDesktopService().searchText()
|
||||
|
||||
this.application.getDesktopService()?.searchText()
|
||||
|
||||
this.resetPagination()
|
||||
|
||||
/* Capture db load state before beginning reloadNotes,
|
||||
@@ -525,7 +531,8 @@ export class NotesViewState {
|
||||
* enter before highlighting desktop search results.
|
||||
*/
|
||||
this.searchSubmitted = true
|
||||
this.application.getDesktopService().searchText(this.noteFilterText)
|
||||
|
||||
this.application.getDesktopService()?.searchText(this.noteFilterText)
|
||||
}
|
||||
|
||||
handleFilterTextChanged = () => {
|
||||
|
||||
Reference in New Issue
Block a user