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

Fix current Uploads count for the current drive #387

Merged
merged 2 commits into from
Nov 29, 2021
Merged
Changes from 1 commit
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
11 changes: 8 additions & 3 deletions app/src/main/java/com/infomaniak/drive/data/models/UploadFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,16 @@ open class UploadFile(
}

private fun allPendingFoldersQuery(realm: Realm): RealmQuery<UploadFile> {
return pendingUploadsQuery(realm, onlyCurrentUser = true, driveIds = currentDriveAndSharedWithMeIds())
.distinct(UploadFile::remoteFolder.name)
}

private fun currentDriveAndSharedWithMeIds(): Array<Int> {
val sharedWithMeDriveIds =
DriveInfosController.getDrives(AccountUtils.currentUserId, sharedWithMe = true).map { it.id }
val currentDriveId = AccountUtils.currentDriveId
val driveIds = arrayOf(currentDriveId, *sharedWithMeDriveIds.toTypedArray())

return pendingUploadsQuery(realm, onlyCurrentUser = true, driveIds = driveIds).distinct(UploadFile::remoteFolder.name)
return arrayOf(currentDriveId, *sharedWithMeDriveIds.toTypedArray())
}

fun getAllPendingUploads(customRealm: Realm? = null): ArrayList<UploadFile> {
Expand Down Expand Up @@ -168,7 +172,8 @@ open class UploadFile(

fun getCurrentUserPendingUploadsCount(folderId: Int? = null): Int {
return getRealmInstance().use { realm ->
pendingUploadsQuery(realm, folderId, true).count().toInt()
val driveIds = currentDriveAndSharedWithMeIds()
pendingUploadsQuery(realm, folderId, true, driveIds).count().toInt()
}
}

Expand Down