-
Notifications
You must be signed in to change notification settings - Fork 40
add mixed timeline when new account added #1171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,7 @@ import kotlinx.collections.immutable.ImmutableList | |||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.collections.immutable.toImmutableList | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.coroutines.CoroutineScope | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.coroutines.flow.Flow | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.coroutines.flow.MutableStateFlow | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.coroutines.flow.distinctUntilChangedBy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.coroutines.flow.flowOf | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import kotlinx.coroutines.flow.map | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -59,6 +60,23 @@ internal class AccountRepository( | |||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| private val _onAdded by lazy { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| MutableStateFlow<UiAccount?>(null) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val onAdded: Flow<UiAccount> by lazy { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| _onAdded | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .mapNotNull { it } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .distinctUntilChangedBy { it.accountKey } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| private val _onRemoved by lazy { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| MutableStateFlow<MicroBlogKey?>(null) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val onRemoved: Flow<MicroBlogKey> by lazy { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| _onRemoved | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .mapNotNull { it } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| .mapNotNull { it } | |
| MutableSharedFlow<UiAccount>(extraBufferCapacity = 1) | |
| } | |
| val onAdded: Flow<UiAccount> by lazy { | |
| _onAdded | |
| .distinctUntilChangedBy { it.accountKey } | |
| } | |
| private val _onRemoved by lazy { | |
| MutableSharedFlow<MicroBlogKey>(extraBufferCapacity = 1) | |
| } | |
| val onRemoved: Flow<MicroBlogKey> by lazy { | |
| _onRemoved |
Copilot
AI
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using MutableStateFlow for events can cause issues as new subscribers will not receive previously emitted events. Consider using SharedFlow or Channel for proper event emission semantics.
| .mapNotNull { it } | |
| MutableSharedFlow<UiAccount>(replay = 0) | |
| } | |
| val onAdded: Flow<UiAccount> by lazy { | |
| _onAdded | |
| .distinctUntilChangedBy { it.accountKey } | |
| } | |
| private val _onRemoved by lazy { | |
| MutableSharedFlow<MicroBlogKey>(replay = 0) | |
| } | |
| val onRemoved: Flow<MicroBlogKey> by lazy { | |
| _onRemoved |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package dev.dimension.flare.ui.presenter.settings | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.Immutable | ||
| import dev.dimension.flare.data.repository.AccountRepository | ||
| import dev.dimension.flare.model.MicroBlogKey | ||
| import dev.dimension.flare.ui.model.UiAccount | ||
| import dev.dimension.flare.ui.presenter.PresenterBase | ||
| import kotlinx.coroutines.flow.Flow | ||
| import org.koin.core.component.KoinComponent | ||
| import org.koin.core.component.inject | ||
|
|
||
| public class AccountEventPresenter : | ||
| PresenterBase<AccountEventPresenter.State>(), | ||
| KoinComponent { | ||
| @Immutable | ||
| public interface State { | ||
| public val onAdded: Flow<UiAccount> | ||
| public val onRemoved: Flow<MicroBlogKey> | ||
| } | ||
|
|
||
| private val accountRepository: AccountRepository by inject() | ||
|
|
||
| @Composable | ||
| override fun body(): State = | ||
| object : State { | ||
| override val onAdded = accountRepository.onAdded | ||
| override val onRemoved = accountRepository.onRemoved | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using UiRssSource.favIconUrl for account icons seems semantically incorrect. Consider creating a dedicated method for account favicon URLs or using a more appropriate API.