-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ared/src/commonMain/kotlin/io/rebble/cobble/shared/database/dao/NotificationChannelDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<NotificationChannel>) | ||
|
||
@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? | ||
} |
14 changes: 14 additions & 0 deletions
14
...ared/src/commonMain/kotlin/io/rebble/cobble/shared/database/entity/NotificationChannel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) |