-
-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(oc-file-list): favorite refresh #17018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c89d5e2
f5a5950
999ae34
cab8e86
3709338
1895aec
ad0cfb8
1d72739
cc97f6b
a3b17e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1680,6 +1680,10 @@ class FileDisplayActivity : | |
| it.setEmptyListMessage(EmptyListState.ONLY_ON_DEVICE) | ||
| } | ||
|
|
||
| it.searchEvent?.searchType == SearchRemoteOperation.SearchType.FAVORITE_SEARCH -> { | ||
| it.setEmptyListMessage(SearchType.FAVORITE_SEARCH) | ||
| } | ||
|
|
||
| else -> it.setEmptyListMessage(SearchType.NO_SEARCH) | ||
| } | ||
| } | ||
|
|
@@ -2163,41 +2167,34 @@ class FileDisplayActivity : | |
| */ | ||
| private fun onRemoveFileOperationFinish(operation: RemoveFileOperation, result: RemoteOperationResult<*>) { | ||
| deleteBatchTracker.onSingleDeleteFinished() | ||
| if (!result.isSuccess && result.isSslRecoverableException) { | ||
| mLastSslUntrustedServerResult = result | ||
| showUntrustedCertDialog(mLastSslUntrustedServerResult) | ||
| return | ||
| } | ||
|
|
||
| if (result.isSuccess) { | ||
| val removedFile = operation.file | ||
| tryStopPlaying(removedFile) | ||
| val leftFragment = this.leftFragment | ||
| val removedFile = operation.file | ||
| tryStopPlaying(removedFile) | ||
| val leftFragment = this.leftFragment | ||
|
|
||
| // check if file is still available, if so do nothing | ||
| val fileAvailable = storageManager.fileExists(removedFile.fileId) | ||
| if (leftFragment is FileFragment && !fileAvailable && removedFile == leftFragment.file) { | ||
| file = storageManager.getFileById(removedFile.parentId) | ||
| resetScrollingAndUpdateActionBar() | ||
| } | ||
| val parentFile = storageManager.getFileById(removedFile.parentId) | ||
| if (parentFile != null && parentFile == getCurrentDir()) { | ||
| updateListOfFilesFragment() | ||
| } else if (leftFragment is OCFileListFragment && | ||
| SearchRemoteOperation.SearchType.FAVORITE_SEARCH == leftFragment.searchEvent?.searchType | ||
| ) { | ||
| leftFragment.adapter?.run { | ||
| val file = files.find { it.fileId == removedFile.fileId } | ||
| if (file != null) { | ||
| val pos = getItemPosition(file) | ||
| files.remove(file) | ||
| notifyItemRemoved(pos) | ||
| } | ||
| } | ||
| } | ||
| supportInvalidateOptionsMenu() | ||
| fetchRecommendedFilesIfNeeded(ignoreETag = true, currentDir) | ||
| } else { | ||
| if (result.isSslRecoverableException) { | ||
| mLastSslUntrustedServerResult = result | ||
| showUntrustedCertDialog(mLastSslUntrustedServerResult) | ||
| // check if file is still available, if so do nothing | ||
| val fileAvailable = storageManager.fileExists(removedFile.fileId) | ||
| if (leftFragment is FileFragment && !fileAvailable && removedFile == leftFragment.file) { | ||
| file = storageManager.getFileById(removedFile.parentId) | ||
| resetScrollingAndUpdateActionBar() | ||
| } | ||
|
|
||
| if (leftFragment is OCFileListFragment) { | ||
| leftFragment.adapter?.removeFile(removedFile) | ||
|
|
||
| if (leftFragment.adapter?.isEmpty == true) { | ||
| val emptyState = leftFragment.searchEvent?.toSearchType() ?: SearchType.NO_SEARCH | ||
| leftFragment.setEmptyListMessage(emptyState) | ||
| } | ||
| } | ||
|
|
||
| supportInvalidateOptionsMenu() | ||
| fetchRecommendedFilesIfNeeded(ignoreETag = true, currentDir) | ||
| } | ||
|
|
||
| override fun onAutoUploadFolderRemoved( | ||
|
|
@@ -2341,38 +2338,7 @@ class FileDisplayActivity : | |
| private fun onRenameFileOperationFinish(operation: RenameFileOperation, result: RemoteOperationResult<*>) { | ||
| val optionalUser = user | ||
| val renamedFile = operation.file | ||
| if (result.isSuccess && optionalUser.isPresent) { | ||
| val currentUser = optionalUser.get() | ||
| val leftFragment = this.leftFragment | ||
| if (leftFragment is FileFragment) { | ||
| if (leftFragment is FileDetailFragment && renamedFile == leftFragment.file) { | ||
| leftFragment.updateFileDetails(renamedFile, currentUser) | ||
| showDetails(renamedFile) | ||
| } else if (leftFragment is PreviewMediaFragment && renamedFile == leftFragment.file) { | ||
| leftFragment.updateFile(renamedFile) | ||
| if (PreviewMediaFragment.canBePreviewed(renamedFile)) { | ||
| val position = leftFragment.position | ||
| startMediaPreview(renamedFile, position, true, true, true, false) | ||
| } else { | ||
| fileOperationsHelper.openFile(renamedFile) | ||
| } | ||
| } else if (leftFragment is PreviewTextFragment && renamedFile == leftFragment.file) { | ||
| (leftFragment as PreviewTextFileFragment).updateFile(renamedFile) | ||
| if (PreviewTextFileFragment.canBePreviewed(renamedFile)) { | ||
| startTextPreview(renamedFile, true) | ||
| } else { | ||
| fileOperationsHelper.openFile(renamedFile) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| val file = storageManager.getFileById(renamedFile.parentId) | ||
| if (file != null && file == getCurrentDir()) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is there any reason to use this condition here @tobiasKaminsky ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need it, yes. If e.g. someone renames a file and directly navigates to another folder. |
||
| updateListOfFilesFragment() | ||
| } | ||
| refreshGalleryFragmentIfNeeded() | ||
| fetchRecommendedFilesIfNeeded(ignoreETag = true, currentDir) | ||
| } else { | ||
| if (!result.isSuccess || optionalUser.isEmpty) { | ||
| DisplayUtils.showSnackMessage( | ||
| this, | ||
| ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()) | ||
|
|
@@ -2382,6 +2348,53 @@ class FileDisplayActivity : | |
| mLastSslUntrustedServerResult = result | ||
| showUntrustedCertDialog(mLastSslUntrustedServerResult) | ||
| } | ||
| return | ||
| } | ||
|
|
||
| val currentUser = optionalUser.get() | ||
| val leftFragment = this.leftFragment | ||
| if (leftFragment is FileFragment) { | ||
| onRenameFileOperationFinishForFileFragment(leftFragment, renamedFile, currentUser) | ||
| } | ||
|
|
||
| updateListOfFilesFragment() | ||
| refreshGalleryFragmentIfNeeded() | ||
| fetchRecommendedFilesIfNeeded(ignoreETag = true, currentDir) | ||
| } | ||
|
|
||
| private fun onRenameFileOperationFinishForFileFragment(fragment: FileFragment, ocFile: OCFile, user: User) { | ||
| if (fragment.file != ocFile) return | ||
|
|
||
| when (fragment) { | ||
| is FileDetailFragment -> { | ||
| fragment.updateFileDetails(ocFile, user) | ||
| showDetails(ocFile) | ||
| } | ||
|
|
||
| is PreviewMediaFragment -> { | ||
| fragment.updateFile(ocFile) | ||
| if (PreviewMediaFragment.canBePreviewed(ocFile)) { | ||
| startMediaPreview( | ||
| ocFile, | ||
| fragment.position, | ||
| true, | ||
| true, | ||
| true, | ||
| false | ||
| ) | ||
| } else { | ||
| fileOperationsHelper.openFile(ocFile) | ||
| } | ||
| } | ||
|
|
||
| is PreviewTextFileFragment -> { | ||
| fragment.updateFile(ocFile) | ||
| if (PreviewTextFileFragment.canBePreviewed(ocFile)) { | ||
| startTextPreview(ocFile, true) | ||
| } else { | ||
| fileOperationsHelper.openFile(ocFile) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adopt to use it like in " setSortOrder(FileSortOrder.Type type"