-
Notifications
You must be signed in to change notification settings - Fork 40
add thread display in status detail #1166
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 |
|---|---|---|
| @@ -1,9 +1,16 @@ | ||
| package dev.dimension.flare.ui.render | ||
|
|
||
| import kotlinx.datetime.toKotlinInstant | ||
| import kotlinx.datetime.toNSDate | ||
| import platform.Foundation.NSDate | ||
| import kotlin.time.Instant | ||
|
|
||
| public actual typealias UiDateTime = NSDate | ||
|
|
||
| internal actual fun Instant.toUi(): UiDateTime = toNSDate() | ||
|
|
||
| internal actual operator fun UiDateTime.compareTo(other: UiDateTime): Int { | ||
| val instant = this.toKotlinInstant() | ||
| val otherInstant = other.toKotlinInstant() | ||
| return instant.compareTo(otherInstant) | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,12 +8,22 @@ import dev.dimension.flare.data.repository.accountServiceFlow | |||||
| import dev.dimension.flare.model.AccountType | ||||||
| import dev.dimension.flare.model.MicroBlogKey | ||||||
| import dev.dimension.flare.ui.model.UiTimeline | ||||||
| import dev.dimension.flare.ui.model.takeSuccess | ||||||
| import dev.dimension.flare.ui.model.toUi | ||||||
| import dev.dimension.flare.ui.presenter.PresenterBase | ||||||
| import dev.dimension.flare.ui.presenter.home.TimelinePresenter | ||||||
| import dev.dimension.flare.ui.presenter.home.TimelineState | ||||||
| import dev.dimension.flare.ui.render.compareTo | ||||||
| import kotlinx.collections.immutable.persistentListOf | ||||||
| import kotlinx.collections.immutable.toPersistentList | ||||||
| import kotlinx.coroutines.ExperimentalCoroutinesApi | ||||||
| import kotlinx.coroutines.flow.Flow | ||||||
| import kotlinx.coroutines.flow.combine | ||||||
| import kotlinx.coroutines.flow.distinctUntilChanged | ||||||
| import kotlinx.coroutines.flow.firstOrNull | ||||||
| import kotlinx.coroutines.flow.flatMapLatest | ||||||
| import kotlinx.coroutines.flow.map | ||||||
| import kotlinx.coroutines.flow.mapNotNull | ||||||
| import org.koin.core.component.KoinComponent | ||||||
| import org.koin.core.component.inject | ||||||
|
|
||||||
|
|
@@ -23,35 +33,76 @@ public class StatusContextPresenter( | |||||
| ) : PresenterBase<TimelineState>(), | ||||||
| KoinComponent { | ||||||
| private val accountRepository: AccountRepository by inject() | ||||||
|
|
||||||
| @OptIn(ExperimentalCoroutinesApi::class) | ||||||
| private val timelinePresenter by lazy { | ||||||
| object : TimelinePresenter() { | ||||||
| private val currentStatusCreatedAtFlow by lazy { | ||||||
| accountServiceFlow( | ||||||
| accountType = accountType, | ||||||
| repository = accountRepository, | ||||||
| ).flatMapLatest { service -> | ||||||
| service.status(statusKey).toUi() | ||||||
| }.mapNotNull { it.takeSuccess() } | ||||||
| .mapNotNull { | ||||||
| if (it.content is UiTimeline.ItemContent.Status) { | ||||||
| it.content.createdAt | ||||||
| } else { | ||||||
| null | ||||||
| } | ||||||
| }.distinctUntilChanged() | ||||||
| } | ||||||
|
|
||||||
| override val loader: Flow<BaseTimelineLoader> by lazy { | ||||||
| accountServiceFlow( | ||||||
| accountType = accountType, | ||||||
| repository = accountRepository, | ||||||
| ).map { service -> | ||||||
| service.context(statusKey) | ||||||
| }.combine(currentStatusCreatedAtFlow) { loader, _ -> | ||||||
| loader | ||||||
| } | ||||||
|
||||||
| } | |
| }.sample(currentStatusCreatedAtFlow) |
Copilot
AI
Aug 12, 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.
Calling firstOrNull() on the flow in every transform operation could be inefficient. Consider passing the current timestamp as a parameter to the transform method or caching it at a higher level.
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.
Converting immutable collection to list with
toList()and then callingdropLast(1)creates unnecessary intermediate collections. Consider usingtake(it.value.replies.size - 1)or direct indexing for better performance.