Manos Chorianopoulos

getSingleCampaignAsync optimizations

......@@ -1279,7 +1279,7 @@ public class swiftApi {
public var subtitle: String?
public let session_uuid: String?
public let subcategory: String?
public let is_new: Bool?
public var is_new: Bool?
public var message: String?
public let loyaltyCampaignId: String?
public let hasExtraFields: Bool?
......@@ -8267,16 +8267,19 @@ public class swiftApi {
func getSingleCampaignAsyncCallback(_ getSingleCampaignData: [AnyHashable: Any]?) -> Void {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
// swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
// func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
// if (campaignsData != nil) {
// DispatchQueue.main.async {
// SwiftEventBus.post("campaigns_retrieved")
// }
// } else {
// }
// }
swiftApi().updateCampaign(sessionUuid: sessionUuid)
SwiftEventBus.post("campaigns_retrieved")
}
} else {
}
}
if let getSingleCampaignDataDictionary = getSingleCampaignData as? [String: Any] {
......@@ -8304,16 +8307,19 @@ public class swiftApi {
func getSingleCampaignFailureCallback(_ error: Error?) -> Void {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
// swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
// func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
// if (campaignsData != nil) {
// DispatchQueue.main.async {
// SwiftEventBus.post("campaigns_retrieved")
// }
// } else {
// }
// }
swiftApi().updateCampaign(sessionUuid: sessionUuid)
SwiftEventBus.post("campaigns_retrieved")
}
} else {
}
}
print("getSingleCampaign error: ")
print(error)
......@@ -9277,6 +9283,26 @@ public class swiftApi {
swiftApi().setCarouselList(carouselArray)
}
public func updateCampaign(sessionUuid: String) {
let allCampaigns = swiftApi().getAllCampaignList()
for tempCampaign in allCampaigns {
if (tempCampaign.session_uuid == sessionUuid) {
tempCampaign.is_new = false
break;
}
}
swiftApi().setUniqueCampaignList(allCampaigns)
let carouselArray = swiftApi().getCarouselList()
for tempCampaign in carouselArray {
if (tempCampaign.session_uuid == sessionUuid) {
tempCampaign.is_new = false
break;
}
}
swiftApi().setCarouselList(carouselArray)
}
public func getCampaignsAsyncNewInternal(_ getCampaignsCallback: @escaping (_ campaignsData: Array<CampaignItemModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void {
var campaignsArray = swiftApi().getAllCampaignList()
swiftApi().getAvailableCouponsAsync({responseDataAvailability in
......