diff --git a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/BlueskyDataSource.kt b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/BlueskyDataSource.kt index d7741eca7..542e0f464 100644 --- a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/BlueskyDataSource.kt +++ b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/BlueskyDataSource.kt @@ -113,6 +113,7 @@ import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull @@ -237,6 +238,7 @@ class BlueskyDataSource( database .userDao() .findByHandleAndHost(name, host, PlatformType.Bluesky) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -256,6 +258,7 @@ class BlueskyDataSource( database .userDao() .findByKey(MicroBlogKey(id, accountKey.host)) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -1824,7 +1827,8 @@ class BlueskyDataSource( .getRoomInfo( roomKey = roomKey, accountKey = accountKey, - ).mapNotNull { + ).distinctUntilChanged() + .mapNotNull { it?.render(accountKey = accountKey) } }, @@ -2031,9 +2035,13 @@ class BlueskyDataSource( ) }, cacheSource = { - database.messageDao().getRoomTimeline(accountKey = accountKey).map { - it.sumOf { it.timeline.unreadCount.toInt() } - } + database + .messageDao() + .getRoomTimeline(accountKey = accountKey) + .distinctUntilChanged() + .map { + it.sumOf { it.timeline.unreadCount.toInt() } + } }, ) diff --git a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/guest/GuestDataSource.kt b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/guest/GuestDataSource.kt index dccb2d8d5..860ef7859 100644 --- a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/guest/GuestDataSource.kt +++ b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/guest/GuestDataSource.kt @@ -27,6 +27,7 @@ import dev.dimension.flare.ui.model.mapper.render import dev.dimension.flare.ui.model.mapper.renderGuest import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.mapNotNull import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -57,6 +58,7 @@ object GuestDataSource : MicroblogDataSource, KoinComponent { database .userDao() .findByHandleAndHost(name, host, PlatformType.Mastodon) + .distinctUntilChanged() .mapNotNull { val content = it?.content if (content is UserContent.Mastodon) { @@ -80,6 +82,7 @@ object GuestDataSource : MicroblogDataSource, KoinComponent { database .userDao() .findByKey(userKey) + .distinctUntilChanged() .mapNotNull { val content = it?.content if (content is UserContent.Mastodon) { diff --git a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/mastodon/MastodonDataSource.kt b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/mastodon/MastodonDataSource.kt index 3dab6f488..0a955bb18 100644 --- a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/mastodon/MastodonDataSource.kt +++ b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/mastodon/MastodonDataSource.kt @@ -59,6 +59,7 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent @@ -272,6 +273,7 @@ class MastodonDataSource( database .userDao() .findByHandleAndHost(name, host, PlatformType.Mastodon) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -288,6 +290,7 @@ class MastodonDataSource( database .userDao() .findByKey(userKey) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -368,6 +371,7 @@ class MastodonDataSource( database .statusDao() .get(statusKey, accountKey) + .distinctUntilChanged() .mapNotNull { it?.content?.render(accountKey, this) } }, ) @@ -383,6 +387,7 @@ class MastodonDataSource( database .emojiDao() .get(accountKey.host) + .distinctUntilChanged() .mapNotNull { it?.toUi()?.toImmutableList() } }, ) diff --git a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/misskey/MisskeyDataSource.kt b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/misskey/MisskeyDataSource.kt index cb632c2c6..89526031b 100644 --- a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/misskey/MisskeyDataSource.kt +++ b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/misskey/MisskeyDataSource.kt @@ -48,6 +48,7 @@ import dev.dimension.flare.ui.presenter.compose.ComposeStatus import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent @@ -191,6 +192,7 @@ class MisskeyDataSource( database .userDao() .findByHandleAndHost(name, host, PlatformType.Misskey) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -212,6 +214,7 @@ class MisskeyDataSource( database .userDao() .findByKey(userKey) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -304,6 +307,7 @@ class MisskeyDataSource( database .statusDao() .get(statusKey, accountKey) + .distinctUntilChanged() .mapNotNull { it?.content?.render(accountKey, this) } }, ) @@ -327,6 +331,7 @@ class MisskeyDataSource( database .emojiDao() .get(accountKey.host) + .distinctUntilChanged() .mapNotNull { it?.toUi()?.toImmutableList() } }, ) diff --git a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/vvo/VVODataSource.kt b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/vvo/VVODataSource.kt index e8d3643ec..e8777c168 100644 --- a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/vvo/VVODataSource.kt +++ b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/vvo/VVODataSource.kt @@ -43,6 +43,7 @@ import dev.dimension.flare.ui.presenter.compose.ComposeStatus import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.launch import kotlinx.datetime.Clock @@ -169,6 +170,7 @@ class VVODataSource( database .userDao() .findByHandleAndHost(name, host, PlatformType.VVo) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -190,6 +192,7 @@ class VVODataSource( database .userDao() .findByKey(userKey) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -283,6 +286,7 @@ class VVODataSource( database .statusDao() .get(statusKey, accountKey) + .distinctUntilChanged() .mapNotNull { it?.content?.render(accountKey, this) } }, ) @@ -312,6 +316,7 @@ class VVODataSource( database .statusDao() .get(statusKey, accountKey) + .distinctUntilChanged() .mapNotNull { it?.content?.render(accountKey, event = this) } }, ) diff --git a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/xqt/XQTDataSource.kt b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/xqt/XQTDataSource.kt index c2b5b4c3f..6be761547 100644 --- a/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/xqt/XQTDataSource.kt +++ b/shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/xqt/XQTDataSource.kt @@ -66,6 +66,7 @@ import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent @@ -219,6 +220,7 @@ class XQTDataSource( database .userDao() .findByHandleAndHost(name, host, PlatformType.xQt) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -247,6 +249,7 @@ class XQTDataSource( database .userDao() .findByKey(userKey) + .distinctUntilChanged() .mapNotNull { it?.render(accountKey) } }, ) @@ -370,6 +373,7 @@ class XQTDataSource( database .statusDao() .get(statusKey, accountKey) + .distinctUntilChanged() .mapNotNull { it?.content?.render(accountKey, this) } }, )