mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Add max selections support for polls (#5726)
This commit is contained in:
committed by
GitHub
parent
173a927bf8
commit
30e4e6339d
@@ -10,6 +10,12 @@ import Foundation
|
||||
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
|
||||
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
|
||||
internal nonisolated enum UntranslatedL10n {
|
||||
/// Decrease votes allowed per person
|
||||
internal static var a11yScreenCreatePollVotesAllowedDecrease: String { return UntranslatedL10n.tr("Untranslated", "a11y_screen_create_poll_votes_allowed_decrease") }
|
||||
/// Increase votes allowed per person
|
||||
internal static var a11yScreenCreatePollVotesAllowedIncrease: String { return UntranslatedL10n.tr("Untranslated", "a11y_screen_create_poll_votes_allowed_increase") }
|
||||
/// Votes allowed per person
|
||||
internal static var screenCreatePollVotesAllowedPerPerson: String { return UntranslatedL10n.tr("Untranslated", "screen_create_poll_votes_allowed_per_person") }
|
||||
/// Search
|
||||
internal static var screenHomeTabSearch: String { return UntranslatedL10n.tr("Untranslated", "screen_home_tab_search") }
|
||||
/// Search for rooms
|
||||
|
||||
@@ -9561,44 +9561,44 @@ nonisolated class PollInteractionHandlerMock: PollInteractionHandlerProtocol, @u
|
||||
|
||||
//MARK: - sendPollResponse
|
||||
|
||||
private let sendPollResponsePollStartIDOptionIDCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = 0
|
||||
var sendPollResponsePollStartIDOptionIDCallsCount: Int {
|
||||
get { sendPollResponsePollStartIDOptionIDCallsCountLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingCallsCount } }
|
||||
set { sendPollResponsePollStartIDOptionIDCallsCountLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = newValue } }
|
||||
private let sendPollResponsePollStartIDAnswerIDsCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDAnswerIDsUnderlyingCallsCount = 0
|
||||
var sendPollResponsePollStartIDAnswerIDsCallsCount: Int {
|
||||
get { sendPollResponsePollStartIDAnswerIDsCallsCountLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingCallsCount } }
|
||||
set { sendPollResponsePollStartIDAnswerIDsCallsCountLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingCallsCount = newValue } }
|
||||
}
|
||||
var sendPollResponsePollStartIDOptionIDCalled: Bool {
|
||||
return sendPollResponsePollStartIDOptionIDCallsCount > 0
|
||||
var sendPollResponsePollStartIDAnswerIDsCalled: Bool {
|
||||
return sendPollResponsePollStartIDAnswerIDsCallsCount > 0
|
||||
}
|
||||
private let sendPollResponsePollStartIDOptionIDReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDOptionIDUnderlyingReceivedArguments: (pollStartID: String, optionID: String)?
|
||||
var sendPollResponsePollStartIDOptionIDReceivedArguments: (pollStartID: String, optionID: String)? {
|
||||
get { sendPollResponsePollStartIDOptionIDReceivedArgumentsLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingReceivedArguments } }
|
||||
set { sendPollResponsePollStartIDOptionIDReceivedArgumentsLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingReceivedArguments = newValue } }
|
||||
private let sendPollResponsePollStartIDAnswerIDsReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDAnswerIDsUnderlyingReceivedArguments: (pollStartID: String, answerIDs: [String])?
|
||||
var sendPollResponsePollStartIDAnswerIDsReceivedArguments: (pollStartID: String, answerIDs: [String])? {
|
||||
get { sendPollResponsePollStartIDAnswerIDsReceivedArgumentsLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingReceivedArguments } }
|
||||
set { sendPollResponsePollStartIDAnswerIDsReceivedArgumentsLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingReceivedArguments = newValue } }
|
||||
}
|
||||
private let sendPollResponsePollStartIDOptionIDReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDOptionIDUnderlyingReceivedInvocations: [(pollStartID: String, optionID: String)] = []
|
||||
var sendPollResponsePollStartIDOptionIDReceivedInvocations: [(pollStartID: String, optionID: String)] {
|
||||
get { sendPollResponsePollStartIDOptionIDReceivedInvocationsLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingReceivedInvocations } }
|
||||
set { sendPollResponsePollStartIDOptionIDReceivedInvocationsLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingReceivedInvocations = newValue } }
|
||||
private let sendPollResponsePollStartIDAnswerIDsReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDAnswerIDsUnderlyingReceivedInvocations: [(pollStartID: String, answerIDs: [String])] = []
|
||||
var sendPollResponsePollStartIDAnswerIDsReceivedInvocations: [(pollStartID: String, answerIDs: [String])] {
|
||||
get { sendPollResponsePollStartIDAnswerIDsReceivedInvocationsLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingReceivedInvocations } }
|
||||
set { sendPollResponsePollStartIDAnswerIDsReceivedInvocationsLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingReceivedInvocations = newValue } }
|
||||
}
|
||||
|
||||
private let sendPollResponsePollStartIDOptionIDReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDOptionIDUnderlyingReturnValue: Result<Void, Error>!
|
||||
var sendPollResponsePollStartIDOptionIDReturnValue: Result<Void, Error>! {
|
||||
get { sendPollResponsePollStartIDOptionIDReturnValueLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingReturnValue } }
|
||||
set { sendPollResponsePollStartIDOptionIDReturnValueLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingReturnValue = newValue } }
|
||||
private let sendPollResponsePollStartIDAnswerIDsReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var sendPollResponsePollStartIDAnswerIDsUnderlyingReturnValue: Result<Void, Error>!
|
||||
var sendPollResponsePollStartIDAnswerIDsReturnValue: Result<Void, Error>! {
|
||||
get { sendPollResponsePollStartIDAnswerIDsReturnValueLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingReturnValue } }
|
||||
set { sendPollResponsePollStartIDAnswerIDsReturnValueLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var sendPollResponsePollStartIDOptionIDClosure: ((String, String) async -> Result<Void, Error>)?
|
||||
nonisolated(unsafe) var sendPollResponsePollStartIDAnswerIDsClosure: ((String, [String]) async -> Result<Void, Error>)?
|
||||
|
||||
@concurrent func sendPollResponse(pollStartID: String, optionID: String) async -> Result<Void, Error> {
|
||||
sendPollResponsePollStartIDOptionIDCallsCountLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingCallsCount += 1 }
|
||||
sendPollResponsePollStartIDOptionIDReceivedArguments = (pollStartID: pollStartID, optionID: optionID)
|
||||
sendPollResponsePollStartIDOptionIDReceivedInvocationsLock.withLock { sendPollResponsePollStartIDOptionIDUnderlyingReceivedInvocations.append((pollStartID: pollStartID, optionID: optionID)) }
|
||||
if let sendPollResponsePollStartIDOptionIDClosure = sendPollResponsePollStartIDOptionIDClosure {
|
||||
return await sendPollResponsePollStartIDOptionIDClosure(pollStartID, optionID)
|
||||
@concurrent func sendPollResponse(pollStartID: String, answerIDs: [String]) async -> Result<Void, Error> {
|
||||
sendPollResponsePollStartIDAnswerIDsCallsCountLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingCallsCount += 1 }
|
||||
sendPollResponsePollStartIDAnswerIDsReceivedArguments = (pollStartID: pollStartID, answerIDs: answerIDs)
|
||||
sendPollResponsePollStartIDAnswerIDsReceivedInvocationsLock.withLock { sendPollResponsePollStartIDAnswerIDsUnderlyingReceivedInvocations.append((pollStartID: pollStartID, answerIDs: answerIDs)) }
|
||||
if let sendPollResponsePollStartIDAnswerIDsClosure = sendPollResponsePollStartIDAnswerIDsClosure {
|
||||
return await sendPollResponsePollStartIDAnswerIDsClosure(pollStartID, answerIDs)
|
||||
} else {
|
||||
return sendPollResponsePollStartIDOptionIDReturnValue
|
||||
return sendPollResponsePollStartIDAnswerIDsReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - endPoll
|
||||
@@ -12772,86 +12772,86 @@ nonisolated class TimelineControllerMock: TimelineControllerProtocol, @unchecked
|
||||
}
|
||||
//MARK: - createPoll
|
||||
|
||||
private let createPollQuestionAnswersPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingCallsCount = 0
|
||||
var createPollQuestionAnswersPollKindCallsCount: Int {
|
||||
get { createPollQuestionAnswersPollKindCallsCountLock.withLock { createPollQuestionAnswersPollKindUnderlyingCallsCount } }
|
||||
set { createPollQuestionAnswersPollKindCallsCountLock.withLock { createPollQuestionAnswersPollKindUnderlyingCallsCount = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = 0
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindCallsCount: Int {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = newValue } }
|
||||
}
|
||||
var createPollQuestionAnswersPollKindCalled: Bool {
|
||||
return createPollQuestionAnswersPollKindCallsCount > 0
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindCalled: Bool {
|
||||
return createPollQuestionAnswersMaxSelectionsPollKindCallsCount > 0
|
||||
}
|
||||
private let createPollQuestionAnswersPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingReceivedArguments: (question: String, answers: [String], pollKind: Poll.Kind)?
|
||||
var createPollQuestionAnswersPollKindReceivedArguments: (question: String, answers: [String], pollKind: Poll.Kind)? {
|
||||
get { createPollQuestionAnswersPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedArguments } }
|
||||
set { createPollQuestionAnswersPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedArguments = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments: (question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)?
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindReceivedArguments: (question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)? {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments = newValue } }
|
||||
}
|
||||
private let createPollQuestionAnswersPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingReceivedInvocations: [(question: String, answers: [String], pollKind: Poll.Kind)] = []
|
||||
var createPollQuestionAnswersPollKindReceivedInvocations: [(question: String, answers: [String], pollKind: Poll.Kind)] {
|
||||
get { createPollQuestionAnswersPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedInvocations } }
|
||||
set { createPollQuestionAnswersPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations: [(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] = []
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocations: [(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
}
|
||||
|
||||
private let createPollQuestionAnswersPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingReturnValue: Result<Void, TimelineControllerError>!
|
||||
var createPollQuestionAnswersPollKindReturnValue: Result<Void, TimelineControllerError>! {
|
||||
get { createPollQuestionAnswersPollKindReturnValueLock.withLock { createPollQuestionAnswersPollKindUnderlyingReturnValue } }
|
||||
set { createPollQuestionAnswersPollKindReturnValueLock.withLock { createPollQuestionAnswersPollKindUnderlyingReturnValue = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue: Result<Void, TimelineControllerError>!
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindReturnValue: Result<Void, TimelineControllerError>! {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var createPollQuestionAnswersPollKindClosure: ((String, [String], Poll.Kind) async -> Result<Void, TimelineControllerError>)?
|
||||
nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindClosure: ((String, [String], Int, Poll.Kind) async -> Result<Void, TimelineControllerError>)?
|
||||
|
||||
@concurrent func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
createPollQuestionAnswersPollKindCallsCountLock.withLock { createPollQuestionAnswersPollKindUnderlyingCallsCount += 1 }
|
||||
createPollQuestionAnswersPollKindReceivedArguments = (question: question, answers: answers, pollKind: pollKind)
|
||||
createPollQuestionAnswersPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedInvocations.append((question: question, answers: answers, pollKind: pollKind)) }
|
||||
if let createPollQuestionAnswersPollKindClosure = createPollQuestionAnswersPollKindClosure {
|
||||
return await createPollQuestionAnswersPollKindClosure(question, answers, pollKind)
|
||||
@concurrent func createPoll(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount += 1 }
|
||||
createPollQuestionAnswersMaxSelectionsPollKindReceivedArguments = (question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)
|
||||
createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations.append((question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)) }
|
||||
if let createPollQuestionAnswersMaxSelectionsPollKindClosure = createPollQuestionAnswersMaxSelectionsPollKindClosure {
|
||||
return await createPollQuestionAnswersMaxSelectionsPollKindClosure(question, answers, maxSelections, pollKind)
|
||||
} else {
|
||||
return createPollQuestionAnswersPollKindReturnValue
|
||||
return createPollQuestionAnswersMaxSelectionsPollKindReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - editPoll
|
||||
|
||||
private let editPollOriginalQuestionAnswersPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount = 0
|
||||
var editPollOriginalQuestionAnswersPollKindCallsCount: Int {
|
||||
get { editPollOriginalQuestionAnswersPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount } }
|
||||
set { editPollOriginalQuestionAnswersPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = 0
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCount: Int {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = newValue } }
|
||||
}
|
||||
var editPollOriginalQuestionAnswersPollKindCalled: Bool {
|
||||
return editPollOriginalQuestionAnswersPollKindCallsCount > 0
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindCalled: Bool {
|
||||
return editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCount > 0
|
||||
}
|
||||
private let editPollOriginalQuestionAnswersPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingReceivedArguments: (eventID: String, question: String, answers: [String], pollKind: Poll.Kind)?
|
||||
var editPollOriginalQuestionAnswersPollKindReceivedArguments: (eventID: String, question: String, answers: [String], pollKind: Poll.Kind)? {
|
||||
get { editPollOriginalQuestionAnswersPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedArguments } }
|
||||
set { editPollOriginalQuestionAnswersPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedArguments = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments: (eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)?
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArguments: (eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)? {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments = newValue } }
|
||||
}
|
||||
private let editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations: [(eventID: String, question: String, answers: [String], pollKind: Poll.Kind)] = []
|
||||
var editPollOriginalQuestionAnswersPollKindReceivedInvocations: [(eventID: String, question: String, answers: [String], pollKind: Poll.Kind)] {
|
||||
get { editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations } }
|
||||
set { editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations: [(eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] = []
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocations: [(eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
}
|
||||
|
||||
private let editPollOriginalQuestionAnswersPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingReturnValue: Result<Void, TimelineControllerError>!
|
||||
var editPollOriginalQuestionAnswersPollKindReturnValue: Result<Void, TimelineControllerError>! {
|
||||
get { editPollOriginalQuestionAnswersPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReturnValue } }
|
||||
set { editPollOriginalQuestionAnswersPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReturnValue = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue: Result<Void, TimelineControllerError>!
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValue: Result<Void, TimelineControllerError>! {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindClosure: ((String, String, [String], Poll.Kind) async -> Result<Void, TimelineControllerError>)?
|
||||
nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure: ((String, String, [String], Int, Poll.Kind) async -> Result<Void, TimelineControllerError>)?
|
||||
|
||||
@concurrent func editPoll(original eventID: String, question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
editPollOriginalQuestionAnswersPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount += 1 }
|
||||
editPollOriginalQuestionAnswersPollKindReceivedArguments = (eventID: eventID, question: question, answers: answers, pollKind: pollKind)
|
||||
editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations.append((eventID: eventID, question: question, answers: answers, pollKind: pollKind)) }
|
||||
if let editPollOriginalQuestionAnswersPollKindClosure = editPollOriginalQuestionAnswersPollKindClosure {
|
||||
return await editPollOriginalQuestionAnswersPollKindClosure(eventID, question, answers, pollKind)
|
||||
@concurrent func editPoll(original eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount += 1 }
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArguments = (eventID: eventID, question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations.append((eventID: eventID, question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)) }
|
||||
if let editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure = editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure {
|
||||
return await editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure(eventID, question, answers, maxSelections, pollKind)
|
||||
} else {
|
||||
return editPollOriginalQuestionAnswersPollKindReturnValue
|
||||
return editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - sendPollResponse
|
||||
@@ -13737,86 +13737,86 @@ nonisolated class TimelineProxyMock: TimelineProxyProtocol, @unchecked Sendable
|
||||
}
|
||||
//MARK: - createPoll
|
||||
|
||||
private let createPollQuestionAnswersPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingCallsCount = 0
|
||||
var createPollQuestionAnswersPollKindCallsCount: Int {
|
||||
get { createPollQuestionAnswersPollKindCallsCountLock.withLock { createPollQuestionAnswersPollKindUnderlyingCallsCount } }
|
||||
set { createPollQuestionAnswersPollKindCallsCountLock.withLock { createPollQuestionAnswersPollKindUnderlyingCallsCount = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = 0
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindCallsCount: Int {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = newValue } }
|
||||
}
|
||||
var createPollQuestionAnswersPollKindCalled: Bool {
|
||||
return createPollQuestionAnswersPollKindCallsCount > 0
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindCalled: Bool {
|
||||
return createPollQuestionAnswersMaxSelectionsPollKindCallsCount > 0
|
||||
}
|
||||
private let createPollQuestionAnswersPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingReceivedArguments: (question: String, answers: [String], pollKind: Poll.Kind)?
|
||||
var createPollQuestionAnswersPollKindReceivedArguments: (question: String, answers: [String], pollKind: Poll.Kind)? {
|
||||
get { createPollQuestionAnswersPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedArguments } }
|
||||
set { createPollQuestionAnswersPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedArguments = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments: (question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)?
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindReceivedArguments: (question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)? {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments = newValue } }
|
||||
}
|
||||
private let createPollQuestionAnswersPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingReceivedInvocations: [(question: String, answers: [String], pollKind: Poll.Kind)] = []
|
||||
var createPollQuestionAnswersPollKindReceivedInvocations: [(question: String, answers: [String], pollKind: Poll.Kind)] {
|
||||
get { createPollQuestionAnswersPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedInvocations } }
|
||||
set { createPollQuestionAnswersPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations: [(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] = []
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocations: [(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
}
|
||||
|
||||
private let createPollQuestionAnswersPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersPollKindUnderlyingReturnValue: Result<Void, TimelineProxyError>!
|
||||
var createPollQuestionAnswersPollKindReturnValue: Result<Void, TimelineProxyError>! {
|
||||
get { createPollQuestionAnswersPollKindReturnValueLock.withLock { createPollQuestionAnswersPollKindUnderlyingReturnValue } }
|
||||
set { createPollQuestionAnswersPollKindReturnValueLock.withLock { createPollQuestionAnswersPollKindUnderlyingReturnValue = newValue } }
|
||||
private let createPollQuestionAnswersMaxSelectionsPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue: Result<Void, TimelineProxyError>!
|
||||
var createPollQuestionAnswersMaxSelectionsPollKindReturnValue: Result<Void, TimelineProxyError>! {
|
||||
get { createPollQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue } }
|
||||
set { createPollQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var createPollQuestionAnswersPollKindClosure: ((String, [String], Poll.Kind) async -> Result<Void, TimelineProxyError>)?
|
||||
nonisolated(unsafe) var createPollQuestionAnswersMaxSelectionsPollKindClosure: ((String, [String], Int, Poll.Kind) async -> Result<Void, TimelineProxyError>)?
|
||||
|
||||
@concurrent func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError> {
|
||||
createPollQuestionAnswersPollKindCallsCountLock.withLock { createPollQuestionAnswersPollKindUnderlyingCallsCount += 1 }
|
||||
createPollQuestionAnswersPollKindReceivedArguments = (question: question, answers: answers, pollKind: pollKind)
|
||||
createPollQuestionAnswersPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersPollKindUnderlyingReceivedInvocations.append((question: question, answers: answers, pollKind: pollKind)) }
|
||||
if let createPollQuestionAnswersPollKindClosure = createPollQuestionAnswersPollKindClosure {
|
||||
return await createPollQuestionAnswersPollKindClosure(question, answers, pollKind)
|
||||
@concurrent func createPoll(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError> {
|
||||
createPollQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount += 1 }
|
||||
createPollQuestionAnswersMaxSelectionsPollKindReceivedArguments = (question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)
|
||||
createPollQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { createPollQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations.append((question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)) }
|
||||
if let createPollQuestionAnswersMaxSelectionsPollKindClosure = createPollQuestionAnswersMaxSelectionsPollKindClosure {
|
||||
return await createPollQuestionAnswersMaxSelectionsPollKindClosure(question, answers, maxSelections, pollKind)
|
||||
} else {
|
||||
return createPollQuestionAnswersPollKindReturnValue
|
||||
return createPollQuestionAnswersMaxSelectionsPollKindReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - editPoll
|
||||
|
||||
private let editPollOriginalQuestionAnswersPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount = 0
|
||||
var editPollOriginalQuestionAnswersPollKindCallsCount: Int {
|
||||
get { editPollOriginalQuestionAnswersPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount } }
|
||||
set { editPollOriginalQuestionAnswersPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = 0
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCount: Int {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount = newValue } }
|
||||
}
|
||||
var editPollOriginalQuestionAnswersPollKindCalled: Bool {
|
||||
return editPollOriginalQuestionAnswersPollKindCallsCount > 0
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindCalled: Bool {
|
||||
return editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCount > 0
|
||||
}
|
||||
private let editPollOriginalQuestionAnswersPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingReceivedArguments: (eventID: String, question: String, answers: [String], pollKind: Poll.Kind)?
|
||||
var editPollOriginalQuestionAnswersPollKindReceivedArguments: (eventID: String, question: String, answers: [String], pollKind: Poll.Kind)? {
|
||||
get { editPollOriginalQuestionAnswersPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedArguments } }
|
||||
set { editPollOriginalQuestionAnswersPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedArguments = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments: (eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)?
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArguments: (eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)? {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArgumentsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedArguments = newValue } }
|
||||
}
|
||||
private let editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations: [(eventID: String, question: String, answers: [String], pollKind: Poll.Kind)] = []
|
||||
var editPollOriginalQuestionAnswersPollKindReceivedInvocations: [(eventID: String, question: String, answers: [String], pollKind: Poll.Kind)] {
|
||||
get { editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations } }
|
||||
set { editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations: [(eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] = []
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocations: [(eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind)] {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations = newValue } }
|
||||
}
|
||||
|
||||
private let editPollOriginalQuestionAnswersPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindUnderlyingReturnValue: Result<Void, TimelineProxyError>!
|
||||
var editPollOriginalQuestionAnswersPollKindReturnValue: Result<Void, TimelineProxyError>! {
|
||||
get { editPollOriginalQuestionAnswersPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReturnValue } }
|
||||
set { editPollOriginalQuestionAnswersPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReturnValue = newValue } }
|
||||
private let editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue: Result<Void, TimelineProxyError>!
|
||||
var editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValue: Result<Void, TimelineProxyError>! {
|
||||
get { editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue } }
|
||||
set { editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValueLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var editPollOriginalQuestionAnswersPollKindClosure: ((String, String, [String], Poll.Kind) async -> Result<Void, TimelineProxyError>)?
|
||||
nonisolated(unsafe) var editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure: ((String, String, [String], Int, Poll.Kind) async -> Result<Void, TimelineProxyError>)?
|
||||
|
||||
@concurrent func editPoll(original eventID: String, question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError> {
|
||||
editPollOriginalQuestionAnswersPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingCallsCount += 1 }
|
||||
editPollOriginalQuestionAnswersPollKindReceivedArguments = (eventID: eventID, question: question, answers: answers, pollKind: pollKind)
|
||||
editPollOriginalQuestionAnswersPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersPollKindUnderlyingReceivedInvocations.append((eventID: eventID, question: question, answers: answers, pollKind: pollKind)) }
|
||||
if let editPollOriginalQuestionAnswersPollKindClosure = editPollOriginalQuestionAnswersPollKindClosure {
|
||||
return await editPollOriginalQuestionAnswersPollKindClosure(eventID, question, answers, pollKind)
|
||||
@concurrent func editPoll(original eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError> {
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindCallsCountLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingCallsCount += 1 }
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedArguments = (eventID: eventID, question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindReceivedInvocationsLock.withLock { editPollOriginalQuestionAnswersMaxSelectionsPollKindUnderlyingReceivedInvocations.append((eventID: eventID, question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)) }
|
||||
if let editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure = editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure {
|
||||
return await editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure(eventID, question, answers, maxSelections, pollKind)
|
||||
} else {
|
||||
return editPollOriginalQuestionAnswersPollKindReturnValue
|
||||
return editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - sendPollResponse
|
||||
|
||||
@@ -11,13 +11,14 @@ import Foundation
|
||||
extension Poll {
|
||||
static func mock(question: String,
|
||||
pollKind: Poll.Kind = .disclosed,
|
||||
maxSelections: Int = 1,
|
||||
options: [Poll.Option],
|
||||
votes: [String: [String]] = [:],
|
||||
ended: Bool = false,
|
||||
createdByAccountOwner: Bool = false) -> Self {
|
||||
.init(question: question,
|
||||
kind: pollKind,
|
||||
maxSelections: 1,
|
||||
maxSelections: maxSelections,
|
||||
options: options,
|
||||
votes: votes,
|
||||
endDate: ended ? Date() : nil,
|
||||
|
||||
@@ -176,17 +176,17 @@ struct TimelineControllerMockConfiguration {
|
||||
return .success(())
|
||||
}
|
||||
|
||||
createPollQuestionAnswersPollKindClosure = { [weak self, timelineProxy] question, answers, pollKind in
|
||||
createPollQuestionAnswersMaxSelectionsPollKindClosure = { [weak self, timelineProxy] question, answers, maxSelections, pollKind in
|
||||
self?.callbacks.send(.messageSentOrEdited)
|
||||
if let timelineProxy {
|
||||
_ = await timelineProxy.createPoll(question: question, answers: answers, pollKind: pollKind)
|
||||
_ = await timelineProxy.createPoll(question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)
|
||||
}
|
||||
return .success(())
|
||||
}
|
||||
|
||||
editPollOriginalQuestionAnswersPollKindClosure = { [timelineProxy] eventID, question, answers, pollKind in
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindClosure = { [timelineProxy] eventID, question, answers, maxSelections, pollKind in
|
||||
if let timelineProxy {
|
||||
_ = await timelineProxy.editPoll(original: eventID, question: question, answers: answers, pollKind: pollKind)
|
||||
_ = await timelineProxy.editPoll(original: eventID, question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind)
|
||||
}
|
||||
return .success(())
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ extension TimelineProxyMock {
|
||||
paginateBackwardsRequestSizeReturnValue = .success(())
|
||||
paginateForwardsRequestSizeReturnValue = .success(())
|
||||
sendReadReceiptForTypeReturnValue = .success(())
|
||||
createPollQuestionAnswersPollKindReturnValue = .success(())
|
||||
editPollOriginalQuestionAnswersPollKindReturnValue = .success(())
|
||||
createPollQuestionAnswersMaxSelectionsPollKindReturnValue = .success(())
|
||||
editPollOriginalQuestionAnswersMaxSelectionsPollKindReturnValue = .success(())
|
||||
|
||||
if let provider = configuration.timelineItemProvider {
|
||||
timelineItemProvider = provider
|
||||
|
||||
@@ -295,6 +295,9 @@ enum A11yIdentifiers {
|
||||
|
||||
struct PollFormScreen {
|
||||
let addOption = "poll_form-add_option"
|
||||
let maxSelections = "poll_form-max_selections"
|
||||
let maxSelectionsDecrement = "poll_form-max_selections-decrement"
|
||||
let maxSelectionsIncrement = "poll_form-max_selections-increment"
|
||||
let pollKind = "poll_form-kind"
|
||||
let question = "poll_form-question"
|
||||
let submit = "poll_form-submit"
|
||||
|
||||
@@ -77,7 +77,18 @@ enum PollFormMode: Hashable {
|
||||
|
||||
struct PollFormScreenViewStateBindings: Equatable {
|
||||
var question = ""
|
||||
var options: [Option] = [.init(), .init()]
|
||||
var options: [Option] = [.init(), .init()] {
|
||||
didSet {
|
||||
maxSelections = clampedMaxSelections
|
||||
}
|
||||
}
|
||||
|
||||
var maxSelections = 1 {
|
||||
didSet {
|
||||
maxSelections = clampedMaxSelections
|
||||
}
|
||||
}
|
||||
|
||||
var isUndisclosed = false
|
||||
|
||||
struct Option: Identifiable, Equatable {
|
||||
@@ -86,13 +97,20 @@ struct PollFormScreenViewStateBindings: Equatable {
|
||||
}
|
||||
|
||||
var hasValidContent: Bool {
|
||||
!question.isEmpty && options.count >= 2 && options.allSatisfy { !$0.text.isEmpty }
|
||||
!question.isEmpty && options.count >= 2 && options.allSatisfy { !$0.text.isEmpty } && maxSelections >= 1 && maxSelections <= options.count
|
||||
}
|
||||
|
||||
var alertInfo: AlertInfo<UUID>?
|
||||
|
||||
static func == (lhs: PollFormScreenViewStateBindings, rhs: PollFormScreenViewStateBindings) -> Bool {
|
||||
lhs.question == rhs.question && lhs.options.map(\.text) == rhs.options.map(\.text) && lhs.isUndisclosed == rhs.isUndisclosed
|
||||
lhs.question == rhs.question &&
|
||||
lhs.options.map(\.text) == rhs.options.map(\.text) &&
|
||||
lhs.maxSelections == rhs.maxSelections &&
|
||||
lhs.isUndisclosed == rhs.isUndisclosed
|
||||
}
|
||||
|
||||
private var clampedMaxSelections: Int {
|
||||
min(max(maxSelections, 1), max(options.count, 1))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +118,7 @@ extension PollFormScreenViewStateBindings {
|
||||
init(poll: Poll) {
|
||||
self.init(question: poll.question,
|
||||
options: poll.options.map { .init(text: $0.text) },
|
||||
maxSelections: min(max(poll.maxSelections, 1), max(poll.options.count, 1)),
|
||||
isUndisclosed: poll.kind == .undisclosed)
|
||||
}
|
||||
}
|
||||
@@ -110,4 +129,6 @@ enum PollFormScreenViewAction {
|
||||
case delete
|
||||
case deleteOption(index: Int)
|
||||
case addOption
|
||||
case decrementMaxSelections
|
||||
case incrementMaxSelections
|
||||
}
|
||||
|
||||
@@ -40,14 +40,15 @@ class PollFormScreenViewModel: PollFormScreenViewModelType, PollFormScreenViewMo
|
||||
case .submit:
|
||||
let question = state.bindings.question
|
||||
let options = state.bindings.options.map(\.text)
|
||||
let maxSelections = state.bindings.maxSelections
|
||||
let pollKind = state.bindings.isUndisclosed ? Poll.Kind.undisclosed : .disclosed
|
||||
|
||||
Task {
|
||||
switch state.mode {
|
||||
case .new:
|
||||
await createPoll(question: question, options: options, pollKind: pollKind)
|
||||
await createPoll(question: question, options: options, maxSelections: maxSelections, pollKind: pollKind)
|
||||
case .edit(let eventID, _):
|
||||
await editPoll(pollStartID: eventID, question: question, options: options, pollKind: pollKind)
|
||||
await editPoll(pollStartID: eventID, question: question, options: options, maxSelections: maxSelections, pollKind: pollKind)
|
||||
}
|
||||
}
|
||||
case .delete:
|
||||
@@ -80,13 +81,17 @@ class PollFormScreenViewModel: PollFormScreenViewModelType, PollFormScreenViewMo
|
||||
return
|
||||
}
|
||||
state.bindings.options.append(.init())
|
||||
case .decrementMaxSelections:
|
||||
state.bindings.maxSelections -= 1
|
||||
case .incrementMaxSelections:
|
||||
state.bindings.maxSelections += 1
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func createPoll(question: String, options: [String], pollKind: Poll.Kind) async {
|
||||
guard case .success = await timelineController.createPoll(question: question, answers: options, pollKind: pollKind) else {
|
||||
private func createPoll(question: String, options: [String], maxSelections: Int, pollKind: Poll.Kind) async {
|
||||
guard case .success = await timelineController.createPoll(question: question, answers: options, maxSelections: maxSelections, pollKind: pollKind) else {
|
||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.errorUnknown))
|
||||
return
|
||||
}
|
||||
@@ -102,8 +107,8 @@ class PollFormScreenViewModel: PollFormScreenViewModelType, PollFormScreenViewMo
|
||||
analytics.trackPollCreated(isUndisclosed: pollKind == .undisclosed, numberOfAnswers: options.count)
|
||||
}
|
||||
|
||||
private func editPoll(pollStartID: String, question: String, options: [String], pollKind: Poll.Kind) async {
|
||||
switch await timelineController.editPoll(original: pollStartID, question: question, answers: options, pollKind: pollKind) {
|
||||
private func editPoll(pollStartID: String, question: String, options: [String], maxSelections: Int, pollKind: Poll.Kind) async {
|
||||
switch await timelineController.editPoll(original: pollStartID, question: question, answers: options, maxSelections: maxSelections, pollKind: pollKind) {
|
||||
case .success:
|
||||
actionsSubject.send(.close)
|
||||
case .failure:
|
||||
|
||||
@@ -22,7 +22,7 @@ struct PollFormScreen: View {
|
||||
Form {
|
||||
questionSection
|
||||
optionsSection
|
||||
showResultsSection
|
||||
settingsSection
|
||||
deletePollSection
|
||||
}
|
||||
.trackAnalyticsIfNeeded(context: context)
|
||||
@@ -106,8 +106,16 @@ struct PollFormScreen: View {
|
||||
focus = nextOptionIndex.map { .option(index: $0) }
|
||||
}
|
||||
|
||||
private var showResultsSection: some View {
|
||||
private var settingsSection: some View {
|
||||
Section {
|
||||
PollFormMaxSelectionsRow(maxSelections: context.maxSelections,
|
||||
maxNumberOfSelections: context.options.count) {
|
||||
context.send(viewAction: .decrementMaxSelections)
|
||||
} incrementAction: {
|
||||
context.send(viewAction: .incrementMaxSelections)
|
||||
}
|
||||
.accessibilityIdentifier(A11yIdentifiers.pollFormScreen.maxSelections)
|
||||
|
||||
ListRow(label: .plain(title: L10n.screenCreatePollAnonymousDesc),
|
||||
kind: .toggle($context.isUndisclosed))
|
||||
.accessibilityIdentifier(A11yIdentifiers.pollFormScreen.pollKind)
|
||||
@@ -160,6 +168,55 @@ private extension View {
|
||||
}
|
||||
}
|
||||
|
||||
private struct PollFormMaxSelectionsRow: View {
|
||||
let maxSelections: Int
|
||||
let maxNumberOfSelections: Int
|
||||
let decrementAction: () -> Void
|
||||
let incrementAction: () -> Void
|
||||
|
||||
var body: some View {
|
||||
ListRow(kind: .custom {
|
||||
HStack(spacing: 16) {
|
||||
Text(UntranslatedL10n.screenCreatePollVotesAllowedPerPerson)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.lineLimit(2)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
HStack(spacing: 8) {
|
||||
Button(action: decrementAction) {
|
||||
Image(systemSymbol: .minus)
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
.disabled(maxSelections <= 1)
|
||||
.buttonStyle(.compound(.tertiary, size: .toolbarIcon))
|
||||
.accessibilityLabel(UntranslatedL10n.a11yScreenCreatePollVotesAllowedDecrease)
|
||||
.accessibilityIdentifier(A11yIdentifiers.pollFormScreen.maxSelectionsDecrement)
|
||||
|
||||
Text("\(maxSelections)")
|
||||
.font(.compound.bodyLGSemibold)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.monospacedDigit()
|
||||
.frame(minWidth: 28)
|
||||
.accessibilityLabel(Text(maxSelections.formatted()))
|
||||
|
||||
Button(action: incrementAction) {
|
||||
Image(systemSymbol: .plus)
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
.disabled(maxSelections >= maxNumberOfSelections)
|
||||
.buttonStyle(.compound(.tertiary, size: .toolbarIcon))
|
||||
.accessibilityLabel(UntranslatedL10n.a11yScreenCreatePollVotesAllowedIncrease)
|
||||
.accessibilityIdentifier(A11yIdentifiers.pollFormScreen.maxSelectionsIncrement)
|
||||
}
|
||||
.layoutPriority(1)
|
||||
}
|
||||
.padding(.horizontal, ListRowPadding.horizontal)
|
||||
.padding(.vertical, ListRowPadding.vertical)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private struct PollFormOptionRow: View {
|
||||
@Environment(\.editMode) var editMode
|
||||
@Binding var text: String
|
||||
|
||||
@@ -42,7 +42,7 @@ enum RoomPollsHistoryScreenViewAction {
|
||||
case filter(RoomPollsHistoryFilter)
|
||||
case end(pollStartID: String)
|
||||
case edit(pollStartID: String, poll: Poll)
|
||||
case sendPollResponse(pollStartID: String, optionID: String)
|
||||
case sendPollResponse(pollStartID: String, answerIDs: [String])
|
||||
case loadMore
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -58,8 +58,8 @@ class RoomPollsHistoryScreenViewModel: RoomPollsHistoryScreenViewModelType, Room
|
||||
updatePollsList(filter: filter)
|
||||
case .loadMore:
|
||||
paginateBackwards()
|
||||
case .sendPollResponse(let pollStartID, let optionID):
|
||||
sendPollResponse(pollStartID: pollStartID, optionID: optionID)
|
||||
case .sendPollResponse(let pollStartID, let answerIDs):
|
||||
sendPollResponse(pollStartID: pollStartID, answerIDs: answerIDs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,10 +117,10 @@ class RoomPollsHistoryScreenViewModel: RoomPollsHistoryScreenViewModelType, Room
|
||||
}
|
||||
}
|
||||
|
||||
private func sendPollResponse(pollStartID: String, optionID: String) {
|
||||
private func sendPollResponse(pollStartID: String, answerIDs: [String]) {
|
||||
Task {
|
||||
do {
|
||||
try await pollInteractionHandler.sendPollResponse(pollStartID: pollStartID, optionID: optionID).get()
|
||||
try await pollInteractionHandler.sendPollResponse(pollStartID: pollStartID, answerIDs: answerIDs).get()
|
||||
} catch {
|
||||
MXLog.error("Failed to send poll response. \(error)")
|
||||
displayError(message: L10n.errorUnknown)
|
||||
|
||||
@@ -62,9 +62,9 @@ struct RoomPollsHistoryScreen: View {
|
||||
PollView(poll: pollTimelineItem.item.poll,
|
||||
state: .full(isEditable: pollTimelineItem.item.isEditable), sender: pollTimelineItem.item.sender) { action in
|
||||
switch action {
|
||||
case .selectOption(let optionID):
|
||||
case .sendResponse(let answerIDs):
|
||||
guard let pollStartID = pollTimelineItem.item.id.eventID else { return }
|
||||
context.send(viewAction: .sendPollResponse(pollStartID: pollStartID, optionID: optionID))
|
||||
context.send(viewAction: .sendPollResponse(pollStartID: pollStartID, answerIDs: answerIDs))
|
||||
case .edit:
|
||||
guard let pollStartID = pollTimelineItem.item.id.eventID else { return }
|
||||
context.send(viewAction: .edit(pollStartID: pollStartID, poll: pollTimelineItem.item.poll))
|
||||
|
||||
@@ -248,9 +248,9 @@ class TimelineInteractionHandler {
|
||||
|
||||
// MARK: Polls
|
||||
|
||||
func sendPollResponse(pollStartID: String, optionID: String) {
|
||||
func sendPollResponse(pollStartID: String, answerIDs: [String]) {
|
||||
Task {
|
||||
let sendPollResponseResult = await pollInteractionHandler.sendPollResponse(pollStartID: pollStartID, optionID: optionID)
|
||||
let sendPollResponseResult = await pollInteractionHandler.sendPollResponse(pollStartID: pollStartID, answerIDs: answerIDs)
|
||||
|
||||
switch sendPollResponseResult {
|
||||
case .success:
|
||||
|
||||
@@ -36,7 +36,7 @@ enum TimelineViewModelAction {
|
||||
}
|
||||
|
||||
enum TimelineViewPollAction {
|
||||
case selectOption(pollStartID: String, optionID: String)
|
||||
case sendResponse(pollStartID: String, answerIDs: [String])
|
||||
case end(pollStartID: String)
|
||||
case edit(pollStartID: String, poll: Poll)
|
||||
}
|
||||
|
||||
@@ -376,8 +376,8 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
|
||||
private func handlePollAction(_ action: TimelineViewPollAction) {
|
||||
switch action {
|
||||
case let .selectOption(pollStartID, optionID):
|
||||
timelineInteractionHandler.sendPollResponse(pollStartID: pollStartID, optionID: optionID)
|
||||
case let .sendResponse(pollStartID, answerIDs):
|
||||
timelineInteractionHandler.sendPollResponse(pollStartID: pollStartID, answerIDs: answerIDs)
|
||||
case let .end(pollStartID):
|
||||
displayAlert(.pollEndConfirmation(pollStartID))
|
||||
case .edit(let eventID, let poll):
|
||||
|
||||
@@ -10,7 +10,7 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
enum PollViewAction {
|
||||
case selectOption(optionID: String)
|
||||
case sendResponse(answerIDs: [String])
|
||||
case edit
|
||||
case end
|
||||
}
|
||||
@@ -100,13 +100,13 @@ struct PollView: View {
|
||||
}
|
||||
|
||||
private func isRemovePreviousSelectionHintEnabled(option: Poll.Option) -> Bool {
|
||||
!poll.hasEnded && poll.hasMaxSelections && !option.isSelected
|
||||
!poll.hasEnded && poll.maxSelections == 1 && poll.hasMaxSelections && !option.isSelected
|
||||
}
|
||||
|
||||
private func pollOption(option: Poll.Option) -> some View {
|
||||
Button {
|
||||
guard !option.isSelected else { return }
|
||||
actionHandler(.selectOption(optionID: option.id))
|
||||
guard let answerIDs = poll.answerIDsAfterSelecting(optionID: option.id) else { return }
|
||||
actionHandler(.sendResponse(answerIDs: answerIDs))
|
||||
feedbackGenerator.impactOccurred()
|
||||
} label: {
|
||||
PollOptionView(pollOption: option,
|
||||
@@ -114,7 +114,25 @@ struct PollView: View {
|
||||
isFinalResult: poll.hasEnded)
|
||||
.foregroundColor(progressBarColor(for: option))
|
||||
}
|
||||
.disabled(poll.hasEnded)
|
||||
.disabled(isOptionDisabled(option))
|
||||
}
|
||||
|
||||
private func isOptionDisabled(_ option: Poll.Option) -> Bool {
|
||||
if poll.hasEnded {
|
||||
return true
|
||||
}
|
||||
|
||||
// Single-choice polls replace the current answer; multi-choice polls keep
|
||||
// at least one answer while enforcing the max.
|
||||
if poll.maxSelections == 1 {
|
||||
return option.isSelected
|
||||
}
|
||||
|
||||
if option.isSelected {
|
||||
return poll.options.filter(\.isSelected).count == 1
|
||||
}
|
||||
|
||||
return poll.hasMaxSelections
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
||||
@@ -26,9 +26,9 @@ struct PollRoomTimelineView: View {
|
||||
state: state,
|
||||
sender: timelineItem.sender) { action in
|
||||
switch action {
|
||||
case .selectOption(let optionID):
|
||||
guard let eventID, let option = poll.options.first(where: { $0.id == optionID }), !option.isSelected else { return }
|
||||
context.send(viewAction: .handlePollAction(.selectOption(pollStartID: eventID, optionID: option.id)))
|
||||
case .sendResponse(let answerIDs):
|
||||
guard let eventID else { return }
|
||||
context.send(viewAction: .handlePollAction(.sendResponse(pollStartID: eventID, answerIDs: answerIDs)))
|
||||
case .edit:
|
||||
guard let eventID else { return }
|
||||
context.send(viewAction: .handlePollAction(.edit(pollStartID: eventID, poll: poll)))
|
||||
|
||||
@@ -17,8 +17,8 @@ class PollInteractionHandler: PollInteractionHandlerProtocol {
|
||||
self.timelineController = timelineController
|
||||
}
|
||||
|
||||
func sendPollResponse(pollStartID: String, optionID: String) async -> Result<Void, Error> {
|
||||
let sendPollResponseResult = await timelineController.sendPollResponse(pollStartID: pollStartID, answers: [optionID])
|
||||
func sendPollResponse(pollStartID: String, answerIDs: [String]) async -> Result<Void, Error> {
|
||||
let sendPollResponseResult = await timelineController.sendPollResponse(pollStartID: pollStartID, answers: answerIDs)
|
||||
analyticsService.trackPollVote()
|
||||
|
||||
return sendPollResponseResult.mapError { $0 }
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
protocol PollInteractionHandlerProtocol {
|
||||
func sendPollResponse(pollStartID: String, optionID: String) async -> Result<Void, Error>
|
||||
func sendPollResponse(pollStartID: String, answerIDs: [String]) async -> Result<Void, Error>
|
||||
func endPoll(pollStartID: String) async -> Result<Void, Error>
|
||||
}
|
||||
|
||||
|
||||
@@ -404,8 +404,8 @@ class TimelineController: TimelineControllerProtocol {
|
||||
|
||||
// MARK: - Polls
|
||||
|
||||
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
switch await activeTimeline.createPoll(question: question, answers: answers, pollKind: pollKind).mapError(TimelineControllerError.timelineProxyError) {
|
||||
func createPoll(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
switch await activeTimeline.createPoll(question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind).mapError(TimelineControllerError.timelineProxyError) {
|
||||
case .success:
|
||||
callbacks.send(.messageSentOrEdited)
|
||||
return .success(())
|
||||
@@ -414,8 +414,8 @@ class TimelineController: TimelineControllerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func editPoll(original eventID: String, question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
await activeTimeline.editPoll(original: eventID, question: question, answers: answers, pollKind: pollKind).mapError(TimelineControllerError.timelineProxyError)
|
||||
func editPoll(original eventID: String, question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||
await activeTimeline.editPoll(original: eventID, question: question, answers: answers, maxSelections: maxSelections, pollKind: pollKind).mapError(TimelineControllerError.timelineProxyError)
|
||||
}
|
||||
|
||||
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, TimelineControllerError> {
|
||||
|
||||
+2
-1
@@ -137,11 +137,12 @@ protocol TimelineControllerProtocol: Sendable {
|
||||
|
||||
// MARK: - Poll
|
||||
|
||||
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError>
|
||||
func createPoll(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError>
|
||||
|
||||
func editPoll(original eventID: String,
|
||||
question: String,
|
||||
answers: [String],
|
||||
maxSelections: Int,
|
||||
pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError>
|
||||
|
||||
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, TimelineControllerError>
|
||||
|
||||
+17
@@ -43,6 +43,23 @@ nonisolated struct Poll: Hashable {
|
||||
options.filter(\.isSelected).count == maxSelections
|
||||
}
|
||||
|
||||
func answerIDsAfterSelecting(optionID: String) -> [String]? {
|
||||
guard options.contains(where: { $0.id == optionID }) else { return nil }
|
||||
|
||||
let selectedOptionIDs = options.filter(\.isSelected).map(\.id)
|
||||
if selectedOptionIDs.contains(optionID) {
|
||||
guard maxSelections > 1, selectedOptionIDs.count > 1 else { return nil }
|
||||
return selectedOptionIDs.filter { $0 != optionID }
|
||||
}
|
||||
|
||||
guard maxSelections > 1 else {
|
||||
return [optionID]
|
||||
}
|
||||
|
||||
guard selectedOptionIDs.count < maxSelections else { return nil }
|
||||
return selectedOptionIDs + [optionID]
|
||||
}
|
||||
|
||||
struct Option: Hashable {
|
||||
let id: String
|
||||
let text: String
|
||||
|
||||
@@ -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)")
|
||||
|
||||
@@ -124,11 +124,12 @@ protocol TimelineProxyProtocol: Sendable {
|
||||
|
||||
func toggleReaction(_ reaction: String, to eventID: TimelineItemIdentifier.EventOrTransactionID) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError>
|
||||
func createPoll(question: String, answers: [String], maxSelections: Int, pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
func editPoll(original eventID: String,
|
||||
question: String,
|
||||
answers: [String],
|
||||
maxSelections: Int,
|
||||
pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
Reference in New Issue
Block a user