fix: don't close popover when previewing file (#1017)

This commit is contained in:
Aman Harwara
2022-05-09 20:52:10 +05:30
committed by GitHub
parent 8ca9e37ae1
commit f35a454614
6 changed files with 126 additions and 135 deletions

View File

@@ -32,6 +32,7 @@ import { SubscriptionState } from './SubscriptionState'
import { SyncState } from './SyncState'
import { TagsState } from './TagsState'
import { WebOrDesktopDevice } from '@/Device/WebOrDesktopDevice'
import { FilePreviewModalState } from './FilePreviewModalState'
export enum AppStateEvent {
TagChanged,
@@ -84,6 +85,7 @@ export class AppState {
readonly notesView: NotesViewState
readonly subscription: SubscriptionState
readonly files: FilesState
readonly filePreviewModal = new FilePreviewModalState()
isSessionsModalVisible = false

View File

@@ -0,0 +1,34 @@
import { SNFile } from '@standardnotes/snjs/dist/@types'
import { action, makeObservable, observable } from 'mobx'
export class FilePreviewModalState {
isOpen = false
currentFile: SNFile | undefined = undefined
otherFiles: SNFile[] = []
constructor() {
makeObservable(this, {
isOpen: observable,
currentFile: observable,
otherFiles: observable,
activate: action,
dismiss: action,
setCurrentFile: action,
})
}
setCurrentFile = (currentFile: SNFile) => {
this.currentFile = currentFile
}
activate = (currentFile: SNFile, otherFiles: SNFile[]) => {
this.currentFile = currentFile
this.otherFiles = otherFiles
this.isOpen = true
}
dismiss = () => {
this.isOpen = false
}
}