Manos Chorianopoulos

fix questionnaire campaign disappear after answer

......@@ -41,6 +41,27 @@ import SwiftEventBus
if (eventArray[0] == "event") {
if (eventArray[1] == "closeArtwork") {
swiftApi().getProfileAsync(getProfileCallback)
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback)
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
}
} else {
}
}
self.navigationController?.popViewController(animated: true)
} else if (eventArray[1] == "addUserTag") {
......
......@@ -797,13 +797,18 @@ public class swiftApi {
SwiftEventBus.post("campaigns_retrieved")
let filteredCampaigns = campaignsArray.filter {
var filteredCampaigns = campaignsArray.filter {
let tempCampaign = $0
let isCcmsOffer = (tempCampaign.ccms_offer != nil) && (tempCampaign.ccms_offer != "") && (tempCampaign.ccms_offer == "true")
let isTelco = (tempCampaign._type != nil && tempCampaign._type == "telco")
return (!(isCcmsOffer || isTelco))
}
if (swiftApi().getConsumer()?.answered == true) {
filteredCampaigns = filteredCampaigns.filter { $0.offer_category != "questionnaire" }
}
getCampaignsCallback(filteredCampaigns);
})
......@@ -1400,6 +1405,7 @@ public class swiftApi {
// profile_metadata
public let badge: String?
public let msisdnList: Array<String>?
public let answered: Bool?
public init() {
......@@ -1441,6 +1447,7 @@ public class swiftApi {
// profile_metadata
self.badge = ""
self.msisdnList = []
self.answered = false
}
public init(dictionary: [String: Any]) {
......@@ -1491,16 +1498,19 @@ public class swiftApi {
self.profile_metadata = profile_metadata_parsed as? [String: Any]? ?? [String: Any]()
self.badge = profile_metadata_parsed["badge"] as? String? ?? ""
self.msisdnList = profile_metadata_parsed["msisdnList"] as? Array<String>? ?? []
self.answered = profile_metadata_parsed["answered"] as? Bool? ?? false
} else {
self.profile_metadata = [String: Any]()
self.badge = ""
self.msisdnList = []
self.answered = false
print("bad json")
}
} catch let error as NSError {
self.profile_metadata = [String: Any]()
self.badge = ""
self.msisdnList = []
self.answered = false
print(error)
}
......@@ -2735,11 +2745,16 @@ public class swiftApi {
public func getCampaignList() -> Array<CampaignItemModel> {
let filteredCampaigns = GlobalVariables.campaigns.filter {
var filteredCampaigns = GlobalVariables.campaigns.filter {
let tempCampaign = $0
let isCcmsOffer = (tempCampaign.ccms_offer != nil) && (tempCampaign.ccms_offer != "") && (tempCampaign.ccms_offer == "true")
let isTelco = (tempCampaign._type != nil && tempCampaign._type == "telco")
return (!isCcmsOffer)
return (!(isCcmsOffer || isTelco))
}
if (swiftApi().getConsumer()?.answered == true) {
filteredCampaigns = filteredCampaigns.filter { $0.offer_category != "questionnaire" }
}
return filteredCampaigns
......