Skip to content

Commit

Permalink
Merge pull request #4435 from parneet-guraya/fix-share-view
Browse files Browse the repository at this point in the history
[BUG] Shares in non-root are not displayed
  • Loading branch information
Aitorbp authored Aug 13, 2024
2 parents a04b210 + c0f49a7 commit 9169d57
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 139 deletions.
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

0 comments on commit 9169d57

Please sign in to comment.