mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Edit poll UX (#2151)
* Add edit poll on room proxy * Add CreatePollMode * Add “edit poll” presentation flow * Add delete poll section * Inject editing poll * Add submit action * Refactor validation logic * Add edit/delete actions * Fix bubble timestamp for polls * Update localisations * Refactor CreatePoll -> PollForm * Refactor tests * Update rust sdk to 0.0.5-november23 * Update confirmation alerts * Add edit support in TimelineItem menu * Refactor a11y id * Cleanup * Fix failing tests * Add tests * Refine isEditable workaround * Refactor timestamp in TimelineItemBubbledStylerView
This commit is contained in:
@@ -2634,6 +2634,27 @@ class RoomProxyMock: RoomProxyProtocol {
|
||||
return createPollQuestionAnswersPollKindReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - editPoll
|
||||
|
||||
var editPollOriginalQuestionAnswersPollKindCallsCount = 0
|
||||
var editPollOriginalQuestionAnswersPollKindCalled: Bool {
|
||||
return editPollOriginalQuestionAnswersPollKindCallsCount > 0
|
||||
}
|
||||
var editPollOriginalQuestionAnswersPollKindReceivedArguments: (eventID: String, question: String, answers: [String], pollKind: Poll.Kind)?
|
||||
var editPollOriginalQuestionAnswersPollKindReceivedInvocations: [(eventID: String, question: String, answers: [String], pollKind: Poll.Kind)] = []
|
||||
var editPollOriginalQuestionAnswersPollKindReturnValue: Result<Void, RoomProxyError>!
|
||||
var editPollOriginalQuestionAnswersPollKindClosure: ((String, String, [String], Poll.Kind) async -> Result<Void, RoomProxyError>)?
|
||||
|
||||
func editPoll(original eventID: String, question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, RoomProxyError> {
|
||||
editPollOriginalQuestionAnswersPollKindCallsCount += 1
|
||||
editPollOriginalQuestionAnswersPollKindReceivedArguments = (eventID: eventID, question: question, answers: answers, pollKind: pollKind)
|
||||
editPollOriginalQuestionAnswersPollKindReceivedInvocations.append((eventID: eventID, question: question, answers: answers, pollKind: pollKind))
|
||||
if let editPollOriginalQuestionAnswersPollKindClosure = editPollOriginalQuestionAnswersPollKindClosure {
|
||||
return await editPollOriginalQuestionAnswersPollKindClosure(eventID, question, answers, pollKind)
|
||||
} else {
|
||||
return editPollOriginalQuestionAnswersPollKindReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - sendPollResponse
|
||||
|
||||
var sendPollResponsePollStartIDAnswersCallsCount = 0
|
||||
|
||||
@@ -67,6 +67,15 @@ extension Poll {
|
||||
.mock(text: "USA 🇺🇸", votes: 2, allVotes: 10)],
|
||||
ended: true)
|
||||
}
|
||||
|
||||
static var emptyDisclosed: Self {
|
||||
mock(question: "What country do you like most?",
|
||||
pollKind: .disclosed,
|
||||
options: [.mock(text: "Italy 🇮🇹", votes: 0, allVotes: 0),
|
||||
.mock(text: "China 🇨🇳", votes: 0, allVotes: 0),
|
||||
.mock(text: "USA 🇺🇸", votes: 0, allVotes: 0)],
|
||||
createdByAccountOwner: true)
|
||||
}
|
||||
}
|
||||
|
||||
extension Poll.Option {
|
||||
@@ -81,13 +90,13 @@ extension Poll.Option {
|
||||
}
|
||||
|
||||
extension PollRoomTimelineItem {
|
||||
static func mock(poll: Poll, isOutgoing: Bool = true) -> Self {
|
||||
static func mock(poll: Poll, isOutgoing: Bool = true, isEditable: Bool = false) -> Self {
|
||||
.init(id: .init(timelineID: UUID().uuidString, eventID: UUID().uuidString),
|
||||
poll: poll,
|
||||
body: "poll",
|
||||
timestamp: "Now",
|
||||
isOutgoing: isOutgoing,
|
||||
isEditable: false,
|
||||
isEditable: isEditable,
|
||||
canBeRepliedTo: true,
|
||||
sender: .init(id: "userID"),
|
||||
properties: .init())
|
||||
|
||||
Reference in New Issue
Block a user