From 9c52cf1e11f24b2f5cf0a0bf4fa1cc8fa1b4ccb7 Mon Sep 17 00:00:00 2001 From: crc-32 Date: Thu, 1 Aug 2024 03:30:09 +0100 Subject: [PATCH] oops ignored important stuff :( --- android/.gitignore | 2 +- .../database/dao/NotificationChannelDao.kt | 28 +++++++++++++++++++ .../database/entity/NotificationChannel.kt | 14 ++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/dao/NotificationChannelDao.kt create mode 100644 android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/entity/NotificationChannel.kt diff --git a/android/.gitignore b/android/.gitignore index 338d487e..4203df09 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -5,6 +5,6 @@ gradle-wrapper.jar /gradlew.bat /local.properties GeneratedPluginRegistrant.java -/shared +/shared/.gradle buildSrc/build buildSrc/.gradle \ No newline at end of file diff --git a/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/dao/NotificationChannelDao.kt b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/dao/NotificationChannelDao.kt new file mode 100644 index 00000000..66b9309a --- /dev/null +++ b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/dao/NotificationChannelDao.kt @@ -0,0 +1,28 @@ +package io.rebble.cobble.shared.database.dao + +import androidx.room.* +import io.rebble.cobble.shared.database.entity.NotificationChannel + +@Dao +interface NotificationChannelDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun insert(notification: NotificationChannel) + + @Insert(onConflict = OnConflictStrategy.IGNORE) + suspend fun insertAllIfNotExists(notifications: List) + + @Update + suspend fun update(notification: NotificationChannel) + + @Delete + suspend fun delete(notification: NotificationChannel) + + @Query("SELECT * FROM NotificationChannel WHERE packageId = :packageId AND channelId = :channelId") + suspend fun get(packageId: String, channelId: String): NotificationChannel? + + @Query("UPDATE NotificationChannel SET shouldNotify = :shouldNotify WHERE packageId = :packageId AND channelId = :channelId") + suspend fun setShouldNotify(packageId: String, channelId: String, shouldNotify: Boolean) + + @Query("SELECT conversationId FROM NotificationChannel WHERE packageId = :packageId AND channelId = :channelId") + suspend fun getConversationId(packageId: String, channelId: String): String? +} \ No newline at end of file diff --git a/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/entity/NotificationChannel.kt b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/entity/NotificationChannel.kt new file mode 100644 index 00000000..ac69b4c0 --- /dev/null +++ b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/database/entity/NotificationChannel.kt @@ -0,0 +1,14 @@ +package io.rebble.cobble.shared.database.entity + +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(primaryKeys = ["packageId", "channelId"]) +data class NotificationChannel( + val packageId: String, + val channelId: String, + val name: String?, + val description: String?, + val conversationId: String?, + val shouldNotify: Boolean, +)