-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shared: Add support for announcements
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
- Loading branch information
1 parent
3d37022
commit 41c85dd
Showing
6 changed files
with
143 additions
and
0 deletions.
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
20 changes: 20 additions & 0 deletions
20
shared/src/commonMain/kotlin/app/opass/ccip/extensions/AnnouncementTable.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,20 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 OPass | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
*/ | ||
|
||
package app.opass.ccip.extensions | ||
|
||
import app.opass.ccip.database.AnnouncementTable | ||
import app.opass.ccip.network.models.fastpass.Announcement | ||
import kotlinx.serialization.json.Json | ||
|
||
internal fun AnnouncementTable.toAnnouncement(): Announcement { | ||
return Announcement( | ||
datetime = this.datetime, | ||
_msg_en = this.msg_en, | ||
_msg_zh = this.msg_zh, | ||
role = Json.decodeFromString<List<String>>(this.role), | ||
url = this.url | ||
) | ||
} |
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
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
29 changes: 29 additions & 0 deletions
29
shared/src/commonMain/kotlin/app/opass/ccip/network/models/fastpass/Announcement.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,29 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 OPass | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
*/ | ||
|
||
package app.opass.ccip.network.models.fastpass | ||
|
||
import app.opass.ccip.extensions.localized | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Announcement( | ||
val datetime: Long, | ||
|
||
@SerialName("msg_en") | ||
val _msg_en: String, | ||
|
||
@SerialName("msg_zh") | ||
val _msg_zh: String, | ||
|
||
val role: List<String>, | ||
|
||
@SerialName("uri") | ||
val url: String | ||
) { | ||
val message: String | ||
get() = localized(_msg_en, _msg_zh) | ||
} |
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