Skip to content

Commit

Permalink
Show new notifications only for file specific errors
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Sep 17, 2024
1 parent 1abcb49 commit 104e3b7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package com.nextcloud.client.jobs.upload
import android.app.PendingIntent
import android.content.Context
import com.nextcloud.client.jobs.notification.WorkerNotificationManager
import com.nextcloud.utils.extensions.isFileSpecificError
import com.owncloud.android.R
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.operations.UploadFileOperation
Expand Down Expand Up @@ -107,7 +108,11 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
setContentText(errorMessage)
}

showNewNotification(uploadFileOperation)
if (resultCode.isFileSpecificError()) {
showNewNotification(uploadFileOperation)
} else {
showNotification()
}
}

private fun getFailedResultTitleId(resultCode: RemoteOperationResult.ResultCode): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.common.operations.RemoteOperation
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
import com.owncloud.android.lib.resources.files.model.RemoteFile
import com.owncloud.android.utils.ErrorMessageAdapter
import com.owncloud.android.utils.FileStorageUtils
Expand Down Expand Up @@ -46,6 +47,28 @@ fun RemoteOperationResult<*>?.getConflictedRemoteIdsWithOfflineOperations(
return result.ifEmpty { null }
}

fun ResultCode.isFileSpecificError(): Boolean {
val errorCodes = listOf(
ResultCode.INSTANCE_NOT_CONFIGURED,
ResultCode.QUOTA_EXCEEDED,
ResultCode.LOCAL_STORAGE_FULL,
ResultCode.WRONG_CONNECTION,
ResultCode.UNAUTHORIZED,
ResultCode.OK_NO_SSL,
ResultCode.MAINTENANCE_MODE,
ResultCode.UNTRUSTED_DOMAIN,
ResultCode.ACCOUNT_NOT_THE_SAME,
ResultCode.ACCOUNT_EXCEPTION,
ResultCode.ACCOUNT_NOT_NEW,
ResultCode.ACCOUNT_NOT_FOUND,
ResultCode.ACCOUNT_USES_STANDARD_PASSWORD,
ResultCode.INCORRECT_ADDRESS,
ResultCode.BAD_OC_VERSION,
)

return !errorCodes.contains(this)
}

@Suppress("Deprecation")
fun RemoteOperationResult<*>?.toOCFile(): List<OCFile>? {
return if (this?.isSuccess == true) {
Expand Down

0 comments on commit 104e3b7

Please sign in to comment.