Reduce API of JoinedRoom, caller must use the Timeline API from liveTimeline instead. (#4731)
This removes lots of boilerplate code.
This commit is contained in:
parent
3cf8237d29
commit
8d115213cc
20 changed files with 258 additions and 651 deletions
|
|
@ -22,7 +22,7 @@ class DefaultEndPollAction @Inject constructor(
|
|||
private val analyticsService: AnalyticsService,
|
||||
) : EndPollAction {
|
||||
override suspend fun execute(pollStartId: EventId): Result<Unit> {
|
||||
return room.endPoll(
|
||||
return room.liveTimeline.endPoll(
|
||||
pollStartId = pollStartId,
|
||||
text = "The poll with event id: $pollStartId has ended."
|
||||
).onSuccess {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DefaultSendPollResponseAction @Inject constructor(
|
|||
private val analyticsService: AnalyticsService,
|
||||
) : SendPollResponseAction {
|
||||
override suspend fun execute(pollStartId: EventId, answerId: String): Result<Unit> {
|
||||
return room.sendPollResponse(
|
||||
return room.liveTimeline.sendPollResponse(
|
||||
pollStartId = pollStartId,
|
||||
answers = listOf(answerId),
|
||||
).onSuccess {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class PollRepository @Inject constructor(
|
|||
pollKind: PollKind,
|
||||
maxSelections: Int,
|
||||
): Result<Unit> = when (existingPollId) {
|
||||
null -> room.createPoll(
|
||||
null -> room.liveTimeline.createPoll(
|
||||
question = question,
|
||||
answers = answers,
|
||||
maxSelections = maxSelections,
|
||||
|
|
|
|||
|
|
@ -121,7 +121,9 @@ class CreatePollPresenterTest {
|
|||
val createPollResult = lambdaRecorder<String, List<String>, Int, PollKind, Result<Unit>> { _, _, _, _ -> Result.success(Unit) }
|
||||
val presenter = createCreatePollPresenter(
|
||||
room = FakeJoinedRoom(
|
||||
createPollResult = createPollResult
|
||||
liveTimeline = FakeTimeline().apply {
|
||||
createPollLambda = createPollResult
|
||||
},
|
||||
),
|
||||
mode = CreatePollMode.NewPoll,
|
||||
)
|
||||
|
|
@ -169,7 +171,9 @@ class CreatePollPresenterTest {
|
|||
}
|
||||
val presenter = createCreatePollPresenter(
|
||||
room = FakeJoinedRoom(
|
||||
createPollResult = createPollResult
|
||||
liveTimeline = FakeTimeline().apply {
|
||||
createPollLambda = createPollResult
|
||||
},
|
||||
),
|
||||
mode = CreatePollMode.NewPoll,
|
||||
)
|
||||
|
|
@ -253,12 +257,8 @@ class CreatePollPresenterTest {
|
|||
@Test
|
||||
fun `when edit poll fails, error is tracked`() = runTest {
|
||||
val error = Exception("cause")
|
||||
val editPollResult = lambdaRecorder { _: EventId, _: String, _: List<String>, _: Int, _: PollKind ->
|
||||
Result.failure<Unit>(error)
|
||||
}
|
||||
val presenter = createCreatePollPresenter(
|
||||
room = FakeJoinedRoom(
|
||||
editPollResult = editPollResult,
|
||||
liveTimeline = timeline,
|
||||
),
|
||||
mode = CreatePollMode.EditPoll(pollEventId),
|
||||
|
|
@ -276,7 +276,7 @@ class CreatePollPresenterTest {
|
|||
awaitPollLoaded().eventSink(CreatePollEvents.SetAnswer(0, "A"))
|
||||
awaitPollLoaded(newAnswer1 = "A").eventSink(CreatePollEvents.Save)
|
||||
advanceUntilIdle() // Wait for the coroutine to finish
|
||||
assert(editPollLambda).isCalledOnce()
|
||||
editPollLambda.assertions().isCalledOnce()
|
||||
assertThat(fakeAnalyticsService.capturedEvents).isEmpty()
|
||||
assertThat(fakeAnalyticsService.trackedErrors).hasSize(1)
|
||||
assertThat(fakeAnalyticsService.trackedErrors).containsExactly(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue