Skip to content
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

[BUG] Shares in non-root are not displayed #4435

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/4435
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Shares in non-root are updated correctly

The items of the "Share" view are updated instantly when create/edit a link or share with users or groups in a non-root file.

https://github.com/owncloud/android/issues/4432
https://github.com/owncloud/android/pull/4435
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
is UIResult.Loading -> {
showLoadingDialog(R.string.common_loading)
}
is UIResult.Success -> {}
is UIResult.Success -> {
// Needs to trigger refresh after creation because creation request returns wrong path resulting list not getting updated.
shareViewModel.refreshSharesFromNetwork()
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ShareViewModel(
refreshSharesFromNetwork()
}

private fun refreshSharesFromNetwork() = runUseCaseWithResultAndUseCachedData(
fun refreshSharesFromNetwork() = runUseCaseWithResultAndUseCachedData(
coroutineDispatcher = coroutineDispatcherProvider.io,
cachedData = sharesLiveData.value,
liveData = _shares,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class CreateRemoteShareOperation(

var expirationDateInMillis: Long = INIT_EXPIRATION_DATE_IN_MILLIS // Expiration date to set for the public link

var retrieveShareDetails = false // To retrieve more info about the just created share

private fun buildRequestUri(baseUri: Uri) =
baseUri.buildUpon()
.appendEncodedPath(OCS_ROUTE)
Expand Down Expand Up @@ -125,14 +123,7 @@ class CreateRemoteShareOperation(
result.data = parseResponse(response!!)
Timber.d("*** Creating new remote share operation completed ")

val emptyShare = result.data.shares.first()

return if (retrieveShareDetails) {
// retrieve more info - PUT only returns the index of the new share
GetRemoteShareOperation(emptyShare.id).execute(client)
} else {
result
}
return result
}

private fun createFormBody(): FormBody {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ class UpdateRemoteShareOperation
*/
var permissions: Int = DEFAULT_PERMISSION

var retrieveShareDetails = false // To retrieve more info about the just updated share

private fun buildRequestUri(baseUri: Uri) =
baseUri.buildUpon()
.appendEncodedPath(OCS_ROUTE)
Expand Down Expand Up @@ -139,14 +137,8 @@ class UpdateRemoteShareOperation
Timber.d("Successful response: $response")
result.data = parseResponse(response!!)
Timber.d("*** Retrieve the index of the new share completed ")
val emptyShare = result.data.shares.first()

return if (retrieveShareDetails) {
// retrieve more info - PUT only returns the index of the new share
GetRemoteShareOperation(emptyShare.id).execute(client)
} else {
result
}
return result
}

private fun createFormBodyBuilder(): FormBody.Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class OCShareService(override val client: OwnCloudClient) : ShareService {
this.name = name
this.password = password
this.expirationDateInMillis = expirationDate
this.retrieveShareDetails = true
}.execute(client)

override fun updateShare(
Expand All @@ -82,7 +81,6 @@ class OCShareService(override val client: OwnCloudClient) : ShareService {
this.password = password
this.expirationDateInMillis = expirationDate
this.permissions = permissions
this.retrieveShareDetails = true
}.execute(client)

override fun deleteShare(remoteId: String): RemoteOperationResult<Unit> =
Expand Down
Loading