mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Create poll UX (#1571)
* Add poll attachment button * Add poll creation feature flag * Setup navigation to CreatePollScreen * Add create/cancel actions * Add create poll screen ui skeleton * Add bindings in CreatePollScreen * Add logics in CreatePollScreen * Cleanup code * Fix option deletion crash * Fix conflicts * Add create poll logic * Add localisations * Fix test build errors * Fix crash * Add UTs * Add accessibility IDs * Add ui tests * Add 240 char limit * Fix addOption hide behavior * Add maxNumberOfOptions * Cleanup code * Move delete workaround in the view model * Use compound delete icon
This commit is contained in:
@@ -684,6 +684,17 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, RoomProxyError> {
|
||||
await Task.dispatch(on: .global()) {
|
||||
do {
|
||||
return try .success(self.room.createPoll(question: question, answers: answers, maxSelections: 1, pollKind: .init(pollKind: pollKind), txnId: genTransactionId()))
|
||||
} catch {
|
||||
MXLog.error("Failed creating a poll: \(error)")
|
||||
return .failure(.failedCreatingPoll)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
/// Force the timeline to load member details so it can populate sender profiles whenever we add a timeline listener
|
||||
@@ -770,3 +781,14 @@ private final class RoomInfoUpdateListener: RoomInfoListener {
|
||||
onUpdateClosure()
|
||||
}
|
||||
}
|
||||
|
||||
private extension MatrixRustSDK.PollKind {
|
||||
init(pollKind: Poll.Kind) {
|
||||
switch pollKind {
|
||||
case .disclosed:
|
||||
self = .disclosed
|
||||
case .undisclosed:
|
||||
self = .undisclosed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ enum RoomProxyError: Error, Equatable {
|
||||
case failedRemovingAvatar
|
||||
case failedUploadingAvatar
|
||||
case failedCheckingPermission
|
||||
case failedCreatingPoll
|
||||
}
|
||||
|
||||
// sourcery: AutoMockable
|
||||
@@ -165,6 +166,8 @@ protocol RoomProxyProtocol {
|
||||
func uploadAvatar(media: MediaInfo) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func canUserRedact(userID: String) async -> Result<Bool, RoomProxyError>
|
||||
|
||||
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, RoomProxyError>
|
||||
}
|
||||
|
||||
extension RoomProxyProtocol {
|
||||
|
||||
@@ -606,7 +606,7 @@ private extension LocationRoomTimelineItemContent.AssetType {
|
||||
}
|
||||
}
|
||||
|
||||
private extension Poll.Kind {
|
||||
extension Poll.Kind {
|
||||
init(pollKind: MatrixRustSDK.PollKind) {
|
||||
switch pollKind {
|
||||
case .disclosed:
|
||||
|
||||
Reference in New Issue
Block a user