catch exception & fix notification intent

This commit is contained in:
Cuong-Tran 2024-10-25 16:44:27 +07:00
parent 5d95c72e03
commit dd29305979
No known key found for this signature in database
GPG Key ID: 733AA7624B9315C2
2 changed files with 34 additions and 7 deletions

View File

@ -629,7 +629,12 @@ class NotificationReceiver : BroadcastReceiver() {
action = Constants.SHORTCUT_LIBRARY_UPDATE_ERRORS
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
}
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
return PendingIntent.getActivity(
context,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
)
}
/**

View File

@ -1,20 +1,42 @@
package tachiyomi.domain.libraryUpdateError.interactor
import logcat.LogPriority
import tachiyomi.core.common.util.lang.withNonCancellableContext
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.libraryUpdateError.interactor.DeleteLibraryUpdateErrors.Result
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateError
import tachiyomi.domain.libraryUpdateError.repository.LibraryUpdateErrorRepository
class InsertLibraryUpdateErrors(
private val libraryUpdateErrorRepository: LibraryUpdateErrorRepository,
) {
suspend fun upsert(libraryUpdateError: LibraryUpdateError) {
return libraryUpdateErrorRepository.upsert(libraryUpdateError)
suspend fun upsert(libraryUpdateError: LibraryUpdateError) = withNonCancellableContext {
try {
libraryUpdateErrorRepository.upsert(libraryUpdateError)
Result.Success
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
return@withNonCancellableContext Result.InternalError(e)
}
}
suspend fun insert(libraryUpdateError: LibraryUpdateError) {
return libraryUpdateErrorRepository.insert(libraryUpdateError)
suspend fun insert(libraryUpdateError: LibraryUpdateError) = withNonCancellableContext {
try {
libraryUpdateErrorRepository.insert(libraryUpdateError)
Result.Success
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
return@withNonCancellableContext Result.InternalError(e)
}
}
suspend fun insertAll(libraryUpdateErrors: List<LibraryUpdateError>) {
return libraryUpdateErrorRepository.insertAll(libraryUpdateErrors)
suspend fun insertAll(libraryUpdateErrors: List<LibraryUpdateError>) = withNonCancellableContext {
try {
libraryUpdateErrorRepository.insertAll(libraryUpdateErrors)
Result.Success
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
return@withNonCancellableContext Result.InternalError(e)
}
}
}