Skip to content

Commit

Permalink
Storage sdk: Remove omhFile from viewmodel and use other variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
hans-hamel committed Jul 4, 2023
1 parent a97443a commit 4f8e7bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FileViewerActivity :
val fileName = if (viewModel.isUpload) {
DocumentFile.fromSingleUri(this, uri)?.name
} else {
viewModel.selectedFile?.name
viewModel.lastFileClicked?.name
} ?: FileViewerViewModel.DEFAULT_FILE_NAME
showUploadFileDialog(uri, fileName)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ class FileViewerActivity :
}

override fun onUpdateClicked(file: OmhFile) {
viewModel.selectedFile = file
viewModel.lastFileClicked = file
viewModel.isUpload = false
filePicker.launch(FileViewerViewModel.ANY_MIME_TYPE)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ class FileViewerViewModel @Inject constructor(
const val DEFAULT_FILE_NAME = "Untitled"
}

var selectedFile: OmhFile? = null
var isUpload = false
var isGridLayoutManager = true
var createFileSelectedType: OmhFileType? = null
private val parentIdStack = Stack<String>().apply { push(ID_ROOT) }
private var lastFileClicked: OmhFile? = null
var lastFileClicked: OmhFile? = null

override fun getInitialState(): FileViewerViewState = FileViewerViewState.Initial

Expand Down Expand Up @@ -141,7 +140,7 @@ class FileViewerViewModel @Inject constructor(
}

private fun updateFile(event: FileViewerViewEvent.UpdateFile) {
val file = selectedFile ?: return
val file = lastFileClicked ?: return

setState(FileViewerViewState.Loading)

Expand Down

0 comments on commit 4f8e7bb

Please sign in to comment.