Skip to content

Commit 505b8dd

Browse files
feat: Store dismissed upcoming event
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent d8bf191 commit 505b8dd

10 files changed

Lines changed: 905 additions & 19 deletions

File tree

app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/24.json

Lines changed: 806 additions & 0 deletions
Large diffs are not rendered by default.

app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ import java.text.SimpleDateFormat
250250
import java.time.Instant
251251
import java.time.ZoneId
252252
import java.time.ZonedDateTime
253-
import java.time.format.DateTimeFormatter
254-
import java.time.format.FormatStyle
255253
import java.util.Date
256254
import java.util.Locale
257255
import java.util.concurrent.ExecutionException
@@ -1397,20 +1395,26 @@ class ChatActivity :
13971395
chatViewModel.upcomingEventViewState.observe(this) { uiState ->
13981396
when (uiState) {
13991397
is ChatViewModel.UpcomingEventUIState.Success -> {
1400-
binding.upcomingEventCard.visibility = View.VISIBLE
1401-
viewThemeUtils.material.themeCardView(binding.upcomingEventCard)
1398+
val hiddenEventKey = "${uiState.event.uri}${uiState.event.start}${uiState.event.summary}"
1399+
if (hiddenEventKey == chatViewModel.hiddenUpcomingEvent) {
1400+
binding.upcomingEventCard.visibility = View.GONE
1401+
} else {
1402+
binding.upcomingEventCard.visibility = View.VISIBLE
1403+
viewThemeUtils.material.themeCardView(binding.upcomingEventCard)
14021404

1403-
binding.upcomingEventContainer.upcomingEventSummary.text = uiState.event.summary
1405+
binding.upcomingEventContainer.upcomingEventSummary.text = uiState.event.summary
14041406

1405-
uiState.event.start?.let { start ->
1406-
val startDateTime = Instant.ofEpochSecond(start).atZone(ZoneId.systemDefault())
1407-
val currentTime = ZonedDateTime.now(ZoneId.systemDefault())
1408-
binding.upcomingEventContainer.upcomingEventTime.text =
1409-
DateUtils(context).getStringForMeetingStartDateTime(startDateTime, currentTime)
1410-
}
1407+
uiState.event.start?.let { start ->
1408+
val startDateTime = Instant.ofEpochSecond(start).atZone(ZoneId.systemDefault())
1409+
val currentTime = ZonedDateTime.now(ZoneId.systemDefault())
1410+
binding.upcomingEventContainer.upcomingEventTime.text =
1411+
DateUtils(context).getStringForMeetingStartDateTime(startDateTime, currentTime)
1412+
}
14111413

1412-
binding.upcomingEventContainer.upcomingEventDismiss.setOnClickListener {
1413-
binding.upcomingEventCard.visibility = View.GONE
1414+
binding.upcomingEventContainer.upcomingEventDismiss.setOnClickListener {
1415+
binding.upcomingEventCard.visibility = View.GONE
1416+
chatViewModel.saveHiddenUpcomingEvent(hiddenEventKey)
1417+
}
14141418
}
14151419
}
14161420

app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class ChatViewModel @Inject constructor(
102102
val mediaPlayerPosition = mediaPlayerManager.mediaPlayerPosition
103103
var chatRoomToken: String = ""
104104
var messageDraft: MessageDraft = MessageDraft()
105+
var hiddenUpcomingEvent: String? = null
105106
lateinit var participantPermissions: ParticipantPermissions
106107

107108
fun getChatRepository(): ChatMessageRepository = chatRepository
@@ -998,6 +999,7 @@ class ChatViewModel @Inject constructor(
998999
@Suppress("Detekt.TooGenericExceptionCaught")
9991000
fun fetchUpcomingEvent(credentials: String, baseUrl: String, roomToken: String) {
10001001
viewModelScope.launch {
1002+
updateHiddenUpcomingEvent()
10011003
try {
10021004
val response = chatNetworkDataSource.getUpcomingEvents(credentials, baseUrl, roomToken)
10031005
val firstEvent = response.ocs?.data?.events?.firstOrNull()
@@ -1079,6 +1081,30 @@ class ChatViewModel @Inject constructor(
10791081
}
10801082
}
10811083

1084+
suspend fun updateHiddenUpcomingEvent() {
1085+
val model = conversationRepository.getLocallyStoredConversation(
1086+
currentUser,
1087+
chatRoomToken
1088+
)
1089+
model?.hiddenUpcomingEvent?.let {
1090+
hiddenUpcomingEvent = it
1091+
}
1092+
}
1093+
1094+
fun saveHiddenUpcomingEvent(value: String) {
1095+
hiddenUpcomingEvent = value
1096+
viewModelScope.launch {
1097+
val model = conversationRepository.getLocallyStoredConversation(
1098+
currentUser,
1099+
chatRoomToken
1100+
)
1101+
model?.let {
1102+
it.hiddenUpcomingEvent = value
1103+
conversationRepository.updateConversation(it)
1104+
}
1105+
}
1106+
}
1107+
10821108
fun pinMessage(credentials: String, url: String, pinUntil: Int = 0) {
10831109
viewModelScope.launch {
10841110
chatRepository.pinMessage(credentials, url, pinUntil).collect {

app/src/main/java/com/nextcloud/talk/conversationlist/data/network/OfflineFirstConversationsRepository.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class OfflineFirstConversationsRepository @Inject constructor(
9393

9494
override fun onNext(model: ConversationModel) {
9595
runBlocking {
96+
val existingEntity = dao.getConversationForUser(user.id!!, model.token).first()
97+
model.hiddenUpcomingEvent = existingEntity?.hiddenUpcomingEvent
9698
_conversationFlow.emit(model)
9799
val entityList = listOf(model.asEntity())
98100
dao.upsertConversations(user.id!!, entityList)

app/src/main/java/com/nextcloud/talk/data/database/dao/ConversationsDao.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface ConversationsDao {
3232
if (existingItem != null) {
3333
val mergedItem = serverItem.copy()
3434
mergedItem.messageDraft = existingItem.messageDraft
35+
mergedItem.hiddenUpcomingEvent = existingItem.hiddenUpcomingEvent
3536
updateConversation(mergedItem)
3637
} else {
3738
insertConversation(serverItem)

app/src/main/java/com/nextcloud/talk/data/database/mappers/ConversationMapUtils.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ fun ConversationModel.asEntity() =
6666
hasImportant = hasImportant,
6767
messageDraft = messageDraft,
6868
hiddenPinnedId = hiddenPinnedId,
69-
lastPinnedId = lastPinnedId
69+
lastPinnedId = lastPinnedId,
70+
hiddenUpcomingEvent = hiddenUpcomingEvent
7071
)
7172

7273
fun ConversationEntity.asModel() =
@@ -123,7 +124,8 @@ fun ConversationEntity.asModel() =
123124
hasImportant = hasImportant,
124125
messageDraft = messageDraft,
125126
hiddenPinnedId = hiddenPinnedId,
126-
lastPinnedId = lastPinnedId
127+
lastPinnedId = lastPinnedId,
128+
hiddenUpcomingEvent = hiddenUpcomingEvent
127129
)
128130

129131
fun Conversation.asEntity(accountId: Long) =

app/src/main/java/com/nextcloud/talk/data/database/model/ConversationEntity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ data class ConversationEntity(
100100
@ColumnInfo(name = "hasImportant") var hasImportant: Boolean = false,
101101
@ColumnInfo(name = "hiddenPinnedId") var hiddenPinnedId: Long? = null,
102102
@ColumnInfo(name = "lastPinnedId") var lastPinnedId: Long? = null,
103-
@ColumnInfo(name = "messageDraft") var messageDraft: MessageDraft? = MessageDraft()
103+
@ColumnInfo(name = "messageDraft") var messageDraft: MessageDraft? = MessageDraft(),
104+
@ColumnInfo(name = "hiddenUpcomingEvent") var hiddenUpcomingEvent: String? = null
104105
// missing/not needed: attendeeId
105106
// missing/not needed: attendeePin
106107
// missing/not needed: attendeePermissions

app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ import java.util.Locale
4848
ChatMessageEntity::class,
4949
ChatBlockEntity::class
5050
],
51-
version = 23,
51+
version = 24,
5252
autoMigrations = [
5353
AutoMigration(from = 9, to = 10),
5454
AutoMigration(from = 16, to = 17, spec = AutoMigration16To17::class),
5555
AutoMigration(from = 19, to = 20),
5656
AutoMigration(from = 20, to = 21),
5757
AutoMigration(from = 21, to = 22),
58-
AutoMigration(from = 22, to = 23)
58+
AutoMigration(from = 22, to = 23),
59+
AutoMigration(from = 23, to = 24)
5960
],
6061
exportSchema = true
6162
)

app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ data class ConversationModel(
6969

7070
// attributes that don't come from API. This should be changed?!
7171
var password: String? = null,
72-
var messageDraft: MessageDraft? = MessageDraft()
72+
var messageDraft: MessageDraft? = MessageDraft(),
73+
var hiddenUpcomingEvent: String? = null
7374
) {
7475

7576
companion object {

gradle/verification-metadata.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18773,6 +18773,11 @@
1877318773
<sha256 value="eb31c2935a606e9a69003242883fbf53649c947c5ae28ac6cba83e26fb0c3510" origin="Generated by Gradle"/>
1877418774
</artifact>
1877518775
</component>
18776+
<component group="com.google.devtools.ksp" name="com.google.devtools.ksp.gradle.plugin" version="2.3.6">
18777+
<artifact name="com.google.devtools.ksp.gradle.plugin-2.3.6.pom">
18778+
<sha256 value="ba778d7727675c1b3d8165772914dfb8631fa2d0a04867730649422c6859e98c" origin="Generated by Gradle"/>
18779+
</artifact>
18780+
</component>
1877618781
<component group="com.google.devtools.ksp" name="symbol-processing" version="2.1.10-1.0.29">
1877718782
<artifact name="symbol-processing-2.1.10-1.0.29.jar">
1877818783
<sha256 value="56c41a8595d0561770ca7aa0dc7de0a095b655b8292a5e1ab02cc7ded4727cfd" origin="Generated by Gradle"/>
@@ -18865,6 +18870,11 @@
1886518870
<sha256 value="7577f46975d7a15eab72bd806f84f33cb81151914c7ccf777fba04fd262b78e8" origin="Generated by Gradle"/>
1886618871
</artifact>
1886718872
</component>
18873+
<component group="com.google.devtools.ksp" name="symbol-processing" version="2.3.6">
18874+
<artifact name="symbol-processing-2.3.6.pom">
18875+
<sha256 value="453588fda8763b0b3f31a744c1d97c95bbc2e439422d37e3280dda64c17adfe9" origin="Generated by Gradle"/>
18876+
</artifact>
18877+
</component>
1886818878
<component group="com.google.devtools.ksp" name="symbol-processing-aa-embeddable" version="2.1.20-2.0.1">
1886918879
<artifact name="symbol-processing-aa-embeddable-2.1.20-2.0.1.jar">
1887018880
<sha256 value="ed26e97d80f51df9e9dcf1b72eb15401b092fb219258f5a25f5c5e5def4ac551" origin="Generated by Gradle"/>
@@ -18929,6 +18939,14 @@
1892918939
<sha256 value="b0d4565342b564fb925ea103ddc17dc4319aadb878f2c67b0de594e6442ede35" origin="Generated by Gradle"/>
1893018940
</artifact>
1893118941
</component>
18942+
<component group="com.google.devtools.ksp" name="symbol-processing-aa-embeddable" version="2.3.6">
18943+
<artifact name="symbol-processing-aa-embeddable-2.3.6.jar">
18944+
<sha256 value="7caea2d426680a6a77007bca60d40ea1c9218f3db6ae9d16c54f0ffefc4e1b5b" origin="Generated by Gradle"/>
18945+
</artifact>
18946+
<artifact name="symbol-processing-aa-embeddable-2.3.6.pom">
18947+
<sha256 value="a1aee745581c03ee59a8962888e0ee0795a27c6c1b55b733252e52bdf1cf23fd" origin="Generated by Gradle"/>
18948+
</artifact>
18949+
</component>
1893218950
<component group="com.google.devtools.ksp" name="symbol-processing-api" version="1.9.0-1.0.13">
1893318951
<artifact name="symbol-processing-api-1.9.0-1.0.13.jar">
1893418952
<sha256 value="76b7d149b26c014b47f8b408ec8a18a59c79ccbb85bea0e60b5e49585250f140" origin="Generated by Gradle"/>
@@ -19065,6 +19083,14 @@
1906519083
<sha256 value="2cb39e9940d4205d061a4d33089d0590fcad5d0350e93dc237139de0bae582b6" origin="Generated by Gradle"/>
1906619084
</artifact>
1906719085
</component>
19086+
<component group="com.google.devtools.ksp" name="symbol-processing-api" version="2.3.6">
19087+
<artifact name="symbol-processing-api-2.3.6.jar">
19088+
<sha256 value="55df837d54b1bfdd7cdbe53bd84deeae374677ec4a729a9af154d3fee3c00230" origin="Generated by Gradle"/>
19089+
</artifact>
19090+
<artifact name="symbol-processing-api-2.3.6.module">
19091+
<sha256 value="7d3c06bb559c9f9af8daae2af83092d9569738142b2e90654b6baddb7e7def89" origin="Generated by Gradle"/>
19092+
</artifact>
19093+
</component>
1906819094
<component group="com.google.devtools.ksp" name="symbol-processing-cmdline" version="2.1.10-1.0.29">
1906919095
<artifact name="symbol-processing-cmdline-2.1.10-1.0.29.jar">
1907019096
<sha256 value="b5c69be50ef939a21c23d1132457ce1566a0aced2c44cabceca8788320df58b8" origin="Generated by Gradle"/>
@@ -19241,6 +19267,14 @@
1924119267
<sha256 value="49cec45a3c52315d09f693080e9f8c7b4e44835e93960d6bc42f878b9832ad38" origin="Generated by Gradle"/>
1924219268
</artifact>
1924319269
</component>
19270+
<component group="com.google.devtools.ksp" name="symbol-processing-common-deps" version="2.3.6">
19271+
<artifact name="symbol-processing-common-deps-2.3.6.jar">
19272+
<sha256 value="f75ece6d1d4a8978fc9cfe2c895c3232347ddbab5c084b04d0ce876b1d7c9604" origin="Generated by Gradle"/>
19273+
</artifact>
19274+
<artifact name="symbol-processing-common-deps-2.3.6.module">
19275+
<sha256 value="cc2d9b61e4d7ca1f9c30701aba7e28b10652ebf9de2c2804af7af334de7b4edd" origin="Generated by Gradle"/>
19276+
</artifact>
19277+
</component>
1924419278
<component group="com.google.devtools.ksp" name="symbol-processing-gradle-plugin" version="2.1.10-1.0.29">
1924519279
<artifact name="symbol-processing-gradle-plugin-2.1.10-1.0.29.jar">
1924619280
<sha256 value="773757b4dcbb900035953661cbfbab6ad04ba5f87b3b5367dc81182bd24dd0ad" origin="Generated by Gradle"/>
@@ -19345,6 +19379,14 @@
1934519379
<sha256 value="dd3e7282432192a0c63459bfa06e737ea99676a9cefcc2bf30c3df41fb8c5065" origin="Generated by Gradle"/>
1934619380
</artifact>
1934719381
</component>
19382+
<component group="com.google.devtools.ksp" name="symbol-processing-gradle-plugin" version="2.3.6">
19383+
<artifact name="symbol-processing-gradle-plugin-2.3.6.jar">
19384+
<sha256 value="156c7c85c2f13b84d9f1fc03b61fd659237ebe59dc12d14ae4c6f4eb3ddb6b45" origin="Generated by Gradle"/>
19385+
</artifact>
19386+
<artifact name="symbol-processing-gradle-plugin-2.3.6.module">
19387+
<sha256 value="7b0e2836390708fa71e839275c77cdf70c613c0aa41f3596fd14ec1585664cc8" origin="Generated by Gradle"/>
19388+
</artifact>
19389+
</component>
1934819390
<component group="com.google.errorprone" name="error_prone_annotation" version="2.41.0">
1934919391
<artifact name="error_prone_annotation-2.41.0.jar">
1935019392
<sha256 value="192e99ad3be8a0a44fe210cdc9b0265601dcb446e521ba922c793e50add413c3" origin="Generated by Gradle"/>

0 commit comments

Comments
 (0)