Code review updates for scoping of functions.
Fix continuation leak.
This commit is contained in:
parent
d44235bd03
commit
def76778e5
@ -26,12 +26,6 @@ open class ActionShareHandler: MVMCoreActionHandlerProtocol {
|
||||
if completed {
|
||||
// Activity was completed, considered finished.
|
||||
continuation.resume()
|
||||
} else if let _ = activityType {
|
||||
// If a specific type of activity failed, the activity controller is still presented, cannot continue yet.
|
||||
if let error = error,
|
||||
let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: MVMCoreActionHandler.getErrorLocation(with: delegateObject?.actionDelegate, actionType: model.actionType)) {
|
||||
MVMCoreLoggingHandler.addError(toLog: errorObject)
|
||||
}
|
||||
} else if let error = error {
|
||||
continuation.resume(throwing: error)
|
||||
} else {
|
||||
|
||||
@ -66,8 +66,8 @@ public struct ActionShareModel: ActionModelProtocol {
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
public init(sharedText: String, sharedType: ActionShareItemModel.SharedType, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||
items = [ActionShareItemModel(type: sharedType, value: sharedText)]
|
||||
public init(items: [ActionShareItemModel], _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||
self.items = items
|
||||
self.extraParameters = extraParameters
|
||||
self.analyticsData = analyticsData
|
||||
}
|
||||
@ -83,24 +83,34 @@ public struct ActionShareModel: ActionModelProtocol {
|
||||
case sharedText
|
||||
}
|
||||
|
||||
private enum DeprecatedCodingKeys: String, CodingKey {
|
||||
case sharedType
|
||||
case sharedText
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
if let items = try typeContainer.decodeIfPresent([ActionShareItemModel].self, forKey: .items) {
|
||||
self.items = items
|
||||
self.init(items: items)
|
||||
} else {
|
||||
// Legacy
|
||||
let type = try typeContainer.decode(ActionShareItemModel.SharedType.self, forKey: .sharedType)
|
||||
var value: Any
|
||||
switch type {
|
||||
case .url:
|
||||
value = try typeContainer.decode(URL.self, forKey: .sharedText)
|
||||
default:
|
||||
value = try typeContainer.decode(String.self, forKey: .sharedText)
|
||||
}
|
||||
items = [ActionShareItemModel(type: type, value: value)]
|
||||
try self.init(deprecatedFrom: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
private init(deprecatedFrom decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: DeprecatedCodingKeys.self)
|
||||
let type = try typeContainer.decode(ActionShareItemModel.SharedType.self, forKey: .sharedType)
|
||||
var value: Any
|
||||
switch type {
|
||||
case .url:
|
||||
value = try typeContainer.decode(URL.self, forKey: .sharedText)
|
||||
default:
|
||||
value = try typeContainer.decode(String.self, forKey: .sharedText)
|
||||
}
|
||||
items = [ActionShareItemModel(type: type, value: value)]
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(actionType, forKey: .actionType)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user