Interact with polls through the TimelineController as well (creation still disabled on threaded timeline as it's not yet supported by the SDK)

This commit is contained in:
Stefan Ceriu
2025-07-22 17:00:09 +03:00
committed by Stefan Ceriu
parent 324a203086
commit ffe2f726e7
8 changed files with 162 additions and 100 deletions
@@ -9,22 +9,22 @@ import Foundation
class PollInteractionHandler: PollInteractionHandlerProtocol {
let analyticsService: AnalyticsService
let roomProxy: JoinedRoomProxyProtocol
let timelineController: TimelineControllerProtocol
init(analyticsService: AnalyticsService, roomProxy: JoinedRoomProxyProtocol) {
init(analyticsService: AnalyticsService, timelineController: TimelineControllerProtocol) {
self.analyticsService = analyticsService
self.roomProxy = roomProxy
self.timelineController = timelineController
}
func sendPollResponse(pollStartID: String, optionID: String) async -> Result<Void, Error> {
let sendPollResponseResult = await roomProxy.timeline.sendPollResponse(pollStartID: pollStartID, answers: [optionID])
let sendPollResponseResult = await timelineController.sendPollResponse(pollStartID: pollStartID, answers: [optionID])
analyticsService.trackPollVote()
return sendPollResponseResult.mapError { $0 }
}
func endPoll(pollStartID: String) async -> Result<Void, Error> {
let endPollResult = await roomProxy.timeline.endPoll(pollStartID: pollStartID,
let endPollResult = await timelineController.endPoll(pollStartID: pollStartID,
text: "The poll with event id: \(pollStartID) has ended")
analyticsService.trackPollEnd()
return endPollResult.mapError { $0 }