Pass around fromPinnedEvents so we can use it to decide whether to forward the event from the main timeline or the pinned events one

This commit is contained in:
Jorge Martín 2025-11-03 14:43:57 +01:00
parent 4df7841452
commit 753322d50e
18 changed files with 38 additions and 29 deletions

View file

@ -35,7 +35,7 @@ interface MessagesEntryPoint : FeatureEntryPoint {
fun navigateToRoomDetails()
fun navigateToRoomMemberDetails(userId: UserId)
fun handlePermalinkClick(data: PermalinkData, pushToBackstack: Boolean)
fun forwardEvent(eventId: EventId)
fun forwardEvent(eventId: EventId, fromPinnedEvents: Boolean)
fun navigateToRoom(roomId: RoomId)
}

View file

@ -35,7 +35,7 @@ import io.element.android.features.messages.api.MessagesEntryPoint
import io.element.android.features.messages.api.MessagesEntryPointNode
import io.element.android.features.messages.impl.attachments.Attachment
import io.element.android.features.messages.impl.attachments.preview.AttachmentsPreviewNode
import io.element.android.features.messages.impl.pinned.PinnedEventsTimelineProvider
import io.element.android.features.messages.impl.pinned.DefaultPinnedEventsTimelineProvider
import io.element.android.features.messages.impl.pinned.list.PinnedMessagesListNode
import io.element.android.features.messages.impl.report.ReportMessageNode
import io.element.android.features.messages.impl.threads.ThreadedMessagesNode
@ -115,7 +115,7 @@ class MessagesFlowNode(
private val roomNamesCache: RoomNamesCache,
private val mentionSpanUpdater: MentionSpanUpdater,
private val mentionSpanTheme: MentionSpanTheme,
private val pinnedEventsTimelineProvider: PinnedEventsTimelineProvider,
private val pinnedEventsTimelineProvider: DefaultPinnedEventsTimelineProvider,
private val timelineController: TimelineController,
private val knockRequestsListEntryPoint: KnockRequestsListEntryPoint,
private val dateFormatter: DateFormatter,
@ -315,9 +315,9 @@ class MessagesFlowNode(
this@MessagesFlowNode.viewInTimeline(eventId)
}
override fun forwardEvent(eventId: EventId) {
override fun forwardEvent(eventId: EventId, fromPinnedEvents: Boolean) {
// Need to go to the parent because of the overlay
callback.forwardEvent(eventId)
callback.forwardEvent(eventId, fromPinnedEvents)
}
}
mediaViewerEntryPoint.createNode(

View file

@ -18,7 +18,7 @@ import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import dev.zacsweers.metro.Inject
import io.element.android.features.messages.impl.pinned.PinnedEventsTimelineProvider
import io.element.android.features.messages.impl.pinned.DefaultPinnedEventsTimelineProvider
import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.matrix.api.room.BaseRoom
@ -35,7 +35,7 @@ import kotlinx.coroutines.flow.onEach
class PinnedMessagesBannerPresenter(
private val room: BaseRoom,
private val itemFactory: PinnedMessagesBannerItemFactory,
private val pinnedEventsTimelineProvider: PinnedEventsTimelineProvider,
private val pinnedEventsTimelineProvider: DefaultPinnedEventsTimelineProvider,
) : Presenter<PinnedMessagesBannerState> {
private val pinnedItems = mutableStateOf<AsyncData<ImmutableList<PinnedMessagesBannerItem>>>(AsyncData.Uninitialized)

View file

@ -26,7 +26,7 @@ import io.element.android.features.messages.impl.UserEventPermissions
import io.element.android.features.messages.impl.actionlist.ActionListState
import io.element.android.features.messages.impl.actionlist.model.TimelineItemAction
import io.element.android.features.messages.impl.link.LinkState
import io.element.android.features.messages.impl.pinned.PinnedEventsTimelineProvider
import io.element.android.features.messages.impl.pinned.DefaultPinnedEventsTimelineProvider
import io.element.android.features.messages.impl.timeline.TimelineRoomInfo
import io.element.android.features.messages.impl.timeline.factories.TimelineItemsFactory
import io.element.android.features.messages.impl.timeline.factories.TimelineItemsFactoryConfig
@ -66,7 +66,7 @@ class PinnedMessagesListPresenter(
@Assisted private val navigator: PinnedMessagesListNavigator,
private val room: JoinedRoom,
timelineItemsFactoryCreator: TimelineItemsFactory.Creator,
private val timelineProvider: PinnedEventsTimelineProvider,
private val timelineProvider: DefaultPinnedEventsTimelineProvider,
private val timelineProtectionPresenter: Presenter<TimelineProtectionState>,
private val linkPresenter: Presenter<LinkState>,
private val snackbarDispatcher: SnackbarDispatcher,

View file

@ -8,7 +8,7 @@
package io.element.android.features.messages.impl.pinned.banner
import com.google.common.truth.Truth.assertThat
import io.element.android.features.messages.impl.pinned.PinnedEventsTimelineProvider
import io.element.android.features.messages.impl.pinned.DefaultPinnedEventsTimelineProvider
import io.element.android.libraries.eventformatter.test.FakePinnedMessagesBannerFormatter
import io.element.android.libraries.matrix.api.room.JoinedRoom
import io.element.android.libraries.matrix.api.sync.SyncService
@ -195,7 +195,7 @@ class PinnedMessagesBannerPresenterTest {
internal fun TestScope.createPinnedEventsTimelineProvider(
room: JoinedRoom = FakeJoinedRoom(),
syncService: SyncService = FakeSyncService(),
) = PinnedEventsTimelineProvider(
) = DefaultPinnedEventsTimelineProvider(
room = room,
syncService = syncService,
dispatchers = testCoroutineDispatchers(),

View file

@ -13,7 +13,7 @@ import io.element.android.features.messages.impl.actionlist.anActionListState
import io.element.android.features.messages.impl.actionlist.model.TimelineItemAction
import io.element.android.features.messages.impl.fixtures.aTimelineItemsFactoryCreator
import io.element.android.features.messages.impl.link.aLinkState
import io.element.android.features.messages.impl.pinned.PinnedEventsTimelineProvider
import io.element.android.features.messages.impl.pinned.DefaultPinnedEventsTimelineProvider
import io.element.android.features.messages.impl.timeline.model.TimelineItem
import io.element.android.features.messages.impl.timeline.protection.aTimelineProtectionState
import io.element.android.libraries.designsystem.utils.snackbar.SnackbarDispatcher
@ -300,7 +300,7 @@ class PinnedMessagesListPresenterTest {
analyticsService: AnalyticsService = FakeAnalyticsService(),
featureFlagService: FakeFeatureFlagService = FakeFeatureFlagService(),
): PinnedMessagesListPresenter {
val timelineProvider = PinnedEventsTimelineProvider(
val timelineProvider = DefaultPinnedEventsTimelineProvider(
room = room,
syncService = syncService,
dispatchers = testCoroutineDispatchers(),

View file

@ -40,7 +40,7 @@ interface RoomDetailsEntryPoint : FeatureEntryPoint {
fun navigateToGlobalNotificationSettings()
fun navigateToRoom(roomId: RoomId, serverNames: List<String>)
fun handlePermalinkClick(data: PermalinkData, pushToBackstack: Boolean)
fun startForwardEventFlow(eventId: EventId)
fun startForwardEventFlow(eventId: EventId, fromPinnedEvents: Boolean)
}
fun createNode(

View file

@ -299,7 +299,7 @@ class RoomDetailsFlowNode(
// Cannot happen
}
override fun forwardEvent(eventId: EventId) {
override fun forwardEvent(eventId: EventId, fromPinnedEvents: Boolean) {
// Cannot happen
}
}
@ -331,8 +331,8 @@ class RoomDetailsFlowNode(
callback.handlePermalinkClick(permalinkData, pushToBackstack = false)
}
override fun forward(eventId: EventId) {
callback.startForwardEventFlow(eventId)
override fun forward(eventId: EventId, fromPinnedEvents: Boolean) {
callback.startForwardEventFlow(eventId, fromPinnedEvents)
}
}
mediaGalleryEntryPoint.createNode(
@ -358,8 +358,8 @@ class RoomDetailsFlowNode(
callback.handlePermalinkClick(data, pushToBackstack)
}
override fun forwardEvent(eventId: EventId) {
callback.startForwardEventFlow(eventId)
override fun forwardEvent(eventId: EventId, fromPinnedEvents: Boolean) {
callback.startForwardEventFlow(eventId, fromPinnedEvents)
}
override fun navigateToRoom(roomId: RoomId) {

View file

@ -103,7 +103,7 @@ class UserProfileFlowNode(
// Cannot happen
}
override fun forwardEvent(eventId: EventId) {
override fun forwardEvent(eventId: EventId, fromPinnedEvents: Boolean) {
// Cannot happen
}
}