Skip to content

Commit 935448c

Browse files
authored
chore(chat): add separator config for "continous" grouping; ignoring granularity with TimeGap (#954)
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent e637b9d commit 935448c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

  • apps/flipcash

apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/ChatViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ internal class ChatViewModel @Inject constructor(
161161
data class ChatDeactivated(val isReadOnly: Boolean) : Event
162162
}
163163

164-
private val separatorConfig = SeparatorConfig.TimeGap()
164+
private val separatorConfig = SeparatorConfig.Continuous()
165165

166166
@OptIn(ExperimentalCoroutinesApi::class)
167167
private val messageStream = stateFlow.mapNotNull { it.chatId }

apps/flipcash/shared/chat-ui/src/main/kotlin/com/flipcash/shared/chat/ui/SeparatorConfig.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,14 @@ sealed interface SeparatorConfig {
2727
before.toLocalDate() != after.toLocalDate()
2828
|| (before - after).absoluteValue > gap
2929
}
30+
31+
data class Continuous(
32+
val gap: Duration = 3.hours,
33+
) : SeparatorConfig {
34+
override val groupingWindow: Duration = Duration.INFINITE
35+
override fun shouldSeparate(before: Instant, after: Instant): Boolean =
36+
before.toLocalDate() != after.toLocalDate()
37+
|| (before - after).absoluteValue > gap
38+
override fun isGrouped(a: Instant, b: Instant): Boolean = true
39+
}
3040
}

0 commit comments

Comments
 (0)