Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a33168f5 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Merge branch '7421-Fix_illegalArgumentException_on_refreshCollectionWorker' into 'main'

7421-Fix_illegalArgumentException_on_refreshCollectionWorker

See merge request !116
parents c1c9610a 1c2c8240
Loading
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -168,11 +168,16 @@ class RefreshCollectionsWorker @AssistedInject constructor(
    }

    val serviceId: Long = inputData.getLong(ARG_SERVICE_ID, -1)

    override fun doWork(): Result {
        val service = db.serviceDao().get(serviceId)
        ?: throw IllegalArgumentException("Service #$serviceId not found")
        if (service == null) {
            Logger.log.severe("Service #$serviceId not found")
            return Result.failure()
        }

        val account = Account(service.accountName, service.accountType)

    override fun doWork(): Result {
        try {
            Logger.log.info("Refreshing ${service.type} collections of service #$service")

@@ -213,7 +218,8 @@ class RefreshCollectionsWorker @AssistedInject constructor(
                .putExtra(SettingsActivity.EXTRA_ACCOUNT, account)
            notifyRefreshError(
                applicationContext.getString(R.string.sync_error_authentication_failed),
                settingsIntent
                settingsIntent,
                account.name
            )
            return Result.failure()
        } catch (e: Exception) {
@@ -225,7 +231,8 @@ class RefreshCollectionsWorker @AssistedInject constructor(
                .build()
            notifyRefreshError(
                applicationContext.getString(R.string.refresh_collections_worker_refresh_couldnt_refresh),
                debugIntent
                debugIntent,
                account.name
            )
            return Result.failure()
        }
@@ -250,7 +257,7 @@ class RefreshCollectionsWorker @AssistedInject constructor(
            completer.set(ForegroundInfo(NotificationUtils.NOTIFY_SYNC_EXPEDITED, notification))
        }

    private fun notifyRefreshError(contentText: String, contentIntent: Intent) {
    private fun notifyRefreshError(contentText: String, contentIntent: Intent, accountName: String) {
        val notify =
            NotificationUtils.newBuilder(applicationContext, NotificationUtils.CHANNEL_GENERAL)
                .setSmallIcon(R.drawable.ic_sync_problem_notify)
@@ -264,7 +271,7 @@ class RefreshCollectionsWorker @AssistedInject constructor(
                        PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
                    )
                )
                .setSubText(account.name)
                .setSubText(accountName)
                .setCategory(NotificationCompat.CATEGORY_ERROR)
                .build()
        NotificationManagerCompat.from(applicationContext)