mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 21:15:21 +00:00
COVIDSafe code from version 1.1
This commit is contained in:
commit
3640e52eb2
330 changed files with 261540 additions and 0 deletions
46
CovidSafe/Feedback/Sources/SendFeedbackAction.swift
Normal file
46
CovidSafe/Feedback/Sources/SendFeedbackAction.swift
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright © 2020 Australian Government All rights reserved.
|
||||
|
||||
import UIKit
|
||||
|
||||
open class SendFeedbackAction: AsyncAction {
|
||||
let issue: Issue
|
||||
let screenshotImageOrNil: UIImage?
|
||||
let onComplete: (Outcome<Void>) -> Void
|
||||
|
||||
var getTargetAction: GetJMCTargeAction!
|
||||
var postFeedbackAction: HTTPPostFeedbackAction!
|
||||
|
||||
public init(issue: Issue, screenshotImageOrNil: UIImage? = nil, onComplete: @escaping (Outcome<Void>) -> Void) {
|
||||
self.issue = issue
|
||||
self.screenshotImageOrNil = screenshotImageOrNil
|
||||
self.onComplete = onComplete
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
override open func run() {
|
||||
getTargetAction = GetJMCTargeAction { outcome in
|
||||
switch outcome {
|
||||
case .success(let JMCTarget):
|
||||
self.postFeedbackToTarget(JMCTarget)
|
||||
case .error(let error):
|
||||
self.finishedExecutingOperationWithOutcome(.error(error))
|
||||
case .cancelled:
|
||||
break
|
||||
}
|
||||
}
|
||||
getTargetAction.start()
|
||||
}
|
||||
|
||||
open func postFeedbackToTarget(_ target: JMCTarget) {
|
||||
postFeedbackAction = HTTPPostFeedbackAction(issue: issue, screenshotImageOrNil: screenshotImageOrNil, target: target) { outcome in
|
||||
self.finishedExecutingOperationWithOutcome(outcome)
|
||||
}
|
||||
postFeedbackAction.start()
|
||||
}
|
||||
|
||||
func finishedExecutingOperationWithOutcome(_ outcome: Outcome<Void>) {
|
||||
finishedExecutingOperation()
|
||||
onComplete(outcome)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue