Skip to content

Commit

Permalink
feat(PublicShareFolderSort): Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Oct 1, 2024
1 parent a8c4f7a commit 22b4063
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ open class FileAdapter(
fun setFiles(newItemList: List<File>, isFileListResetNeeded: Boolean = false) {
fileList = RealmList(*newItemList.toTypedArray())
hideLoading()
// isFileListResetNeeded is used because when sorting file in PublicShareListFragment, the animation of the asynclist
// is bugged, so we just redraw the whole list. As it's only once it's not a problem
if (fileAsyncListDiffer == null || isFileListResetNeeded) {
notifyDataSetChanged()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,7 @@ class PublicShareListFragment : FileListFragment() {
openFolder(file)
} else {
multiSelectManager.isMultiSelectAuthorized = false
val fileList = file?.let(::listOf) ?: listOf()
publicShareViewModel.childrenLiveData.postValue(
PublicShareFilesResult(fileList, shouldUpdate = true, isNewSort = false)
)
publicShareViewModel.setSingleRootFile(file)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ class PublicShareViewModel(application: Application, val savedStateHandle: Saved
buildArchiveResult.postValue(result)
}

fun setSingleRootFile(file: File?) {
val fileList = file?.let(::listOf) ?: listOf()
childrenLiveData.postValue(
PublicShareFilesResult(fileList, shouldUpdate = true, isNewSort = false)
)
}

fun fetchCacheFileForAction(file: File?, action: DownloadAction, navigateToDownloadDialog: suspend () -> Unit) {
viewModelScope.launch(Dispatchers.IO) {
runCatching {
Expand Down

0 comments on commit 22b4063

Please sign in to comment.