mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add max selections support for polls (#5726)
This commit is contained in:
committed by
GitHub
parent
173a927bf8
commit
30e4e6339d
@@ -494,12 +494,15 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
|
||||
// MARK: - Polls
|
||||
|
||||
func createPoll(question: String, answers: [String],
|
||||
func createPoll(question: String, answers: [String], maxSelections: Int,
|
||||
pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError> {
|
||||
MXLog.info("Creating poll")
|
||||
|
||||
do {
|
||||
try await timeline.createPoll(question: question, answers: answers, maxSelections: 1, pollKind: .init(pollKind: pollKind))
|
||||
try await timeline.createPoll(question: question,
|
||||
answers: answers,
|
||||
maxSelections: UInt8(max(1, min(maxSelections, answers.count))),
|
||||
pollKind: .init(pollKind: pollKind))
|
||||
|
||||
MXLog.info("Finished creating poll")
|
||||
|
||||
@@ -513,6 +516,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
func editPoll(original eventID: String,
|
||||
question: String,
|
||||
answers: [String],
|
||||
maxSelections: Int,
|
||||
pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError> {
|
||||
MXLog.info("Editing poll with eventID: \(eventID)")
|
||||
|
||||
@@ -522,7 +526,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
try await timeline.edit(eventOrTransactionId: originalEvent.eventOrTransactionId,
|
||||
newContent: .pollStart(pollData: .init(question: question,
|
||||
answers: answers,
|
||||
maxSelections: 1,
|
||||
maxSelections: UInt8(max(1, min(maxSelections, answers.count))),
|
||||
pollKind: .init(pollKind: pollKind))))
|
||||
|
||||
MXLog.info("Finished editing poll with eventID: \(eventID)")
|
||||
|
||||
Reference in New Issue
Block a user