Polls refinements (#1608)

* Refine focus behavior

* Begin draft mode

* Add alert on poll form

* Add poll ended asset

* Add fallback text for ended poll event

* Cleanup

* Fix assets

* Remove poll feature flags

* Fix UI tests

* Fix ui tests

* Refine discard poll alert

* Remove unused import

* Rename hasDraftContent -> hasContent

* Restore createPoll-2 ref screenshots
This commit is contained in:
Alfonso Grillo
2023-09-01 15:55:11 +02:00
committed by GitHub
parent 41662a5313
commit 9b313b814e
36 changed files with 458 additions and 89 deletions
@@ -712,10 +712,10 @@ class RoomProxy: RoomProxyProtocol {
}
}
func endPoll(pollStartID: String) async -> Result<Void, RoomProxyError> {
func endPoll(pollStartID: String, text: String) async -> Result<Void, RoomProxyError> {
await Task.dispatch(on: .global()) {
do {
return try .success(self.room.endPoll(pollStartId: pollStartID, text: .init(), txnId: genTransactionId()))
return try .success(self.room.endPoll(pollStartId: pollStartID, text: text, txnId: genTransactionId()))
} catch {
MXLog.error("Failed ending a poll: \(error), pollStartID: \(pollStartID)")
return .failure(.failedEndingPoll)
@@ -173,7 +173,7 @@ protocol RoomProxyProtocol {
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, RoomProxyError>
func endPoll(pollStartID: String) async -> Result<Void, RoomProxyError>
func endPoll(pollStartID: String, text: String) async -> Result<Void, RoomProxyError>
}
extension RoomProxyProtocol {
@@ -69,9 +69,6 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
previousAvatarURLString: prevAvatarUrl,
isOutgoing: isOutgoing)
case .poll(question: let question, kind: let kind, maxSelections: let maxSelections, answers: let answers, votes: let votes, endTime: let endTime):
guard ServiceLocator.shared.settings.pollsInTimelineEnabled else {
return nil
}
return buildPollTimelineItem(question, kind, maxSelections, answers, votes, endTime, eventItemProxy, isOutgoing)
}
}