fix: all notifications going to the same activity

This commit is contained in:
rebelonion 2024-03-17 17:56:53 -05:00
parent 89a54b4509
commit b0e46cd904
2 changed files with 9 additions and 4 deletions

View file

@ -20,6 +20,7 @@ import ani.dantotsu.R
import ani.dantotsu.connections.comments.CommentsAPI
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.util.Logger
import eu.kanade.tachiyomi.data.notification.Notifications
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -152,6 +153,8 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
color: String,
imageUrl: String
): android.app.Notification? {
Logger.log("Creating notification of type $notificationType" +
", message: $message, title: $title, mediaId: $mediaId, commentId: $commentId")
val notification = when (notificationType) {
NotificationType.COMMENT_WARNING -> {
val intent = Intent(applicationContext, MainActivity::class.java).apply {
@ -162,7 +165,7 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
}
val pendingIntent = PendingIntent.getActivity(
applicationContext,
0,
commentId,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
@ -185,7 +188,7 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
}
val pendingIntent = PendingIntent.getActivity(
applicationContext,
0,
commentId,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
@ -214,7 +217,7 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
}
val pendingIntent = PendingIntent.getActivity(
applicationContext,
0,
System.currentTimeMillis().toInt(),
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)

View file

@ -16,6 +16,7 @@ import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.profile.activity.ActivityItemBuilder
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.util.Logger
import eu.kanade.tachiyomi.data.notification.Notifications
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -78,12 +79,13 @@ class AnilistNotificationWorker(appContext: Context, workerParams: WorkerParamet
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
putExtra("FRAGMENT_TO_LOAD", "NOTIFICATIONS")
if (notificationId != null) {
Logger.log("notificationId: $notificationId")
putExtra("activityId", notificationId)
}
}
val pendingIntent = PendingIntent.getActivity(
applicationContext,
0,
notificationId ?: 0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)