Timeline : makes sure to use the right timeline when making some action (edit, reply, reaction)

This commit is contained in:
ganfra 2024-04-24 16:42:35 +02:00
parent a6d8209407
commit fed1733cb5
7 changed files with 99 additions and 22 deletions

View file

@ -32,6 +32,7 @@ import io.element.android.libraries.matrix.api.poll.PollKind
import io.element.android.libraries.matrix.api.room.location.AssetType
import io.element.android.libraries.matrix.api.room.powerlevels.MatrixRoomPowerLevels
import io.element.android.libraries.matrix.api.room.powerlevels.UserRoleChange
import io.element.android.libraries.matrix.api.timeline.TimelineProvider
import io.element.android.libraries.matrix.api.timeline.Timeline
import io.element.android.libraries.matrix.api.timeline.ReceiptType
import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.matrix.api.timeline
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.libraries.di.RoomScope
import io.element.android.libraries.matrix.api.room.MatrixRoom
import javax.inject.Inject
/**
* This interface defines a way to get the active timeline.
* It could be the current room timeline, or a timeline for a specific event.
*/
interface TimelineProvider {
suspend fun getActiveTimeline(): Timeline
}
/**
* Default implementation of [TimelineProvider] that provides the live timeline of a room.
*/
@ContributesBinding(RoomScope::class)
class LiveTimelineProvider @Inject constructor(
private val room: MatrixRoom,
) : TimelineProvider {
override suspend fun getActiveTimeline(): Timeline = room.liveTimeline
}