Manos Chorianopoulos

fix refreshing seasonals async

......@@ -41,12 +41,53 @@ import SwiftEventBus
SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in
print("===== SwiftEventBus ccms_retrieved =====")
self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
self.seasonalList = swiftApi().getSeasonalList()
if (seasonalList.count > 0) {
for seasonalItem in self.seasonalList {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = seasonalItem._title
newCampaign._logo_url = seasonalItem._imageUrl
newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
self.campaigns.append(newCampaign)
}
}
self.tableView.reloadData()
}
SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in
print("===== SwiftEventBus campaigns_retrieved =====")
self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
self.seasonalList = swiftApi().getSeasonalList()
if (seasonalList.count > 0) {
for seasonalItem in self.seasonalList {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = seasonalItem._title
newCampaign._logo_url = seasonalItem._imageUrl
newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
self.campaigns.append(newCampaign)
}
}
self.tableView.reloadData()
}
SwiftEventBus.onMainThread(self, name: "seasonals_retrieved") { result in
print("===== SwiftEventBus seasonals_retrieved =====")
self.seasonalList = swiftApi().getSeasonalList()
if (seasonalList.count > 0) {
for seasonalItem in self.seasonalList {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = seasonalItem._title
newCampaign._logo_url = seasonalItem._imageUrl
newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
self.campaigns.append(newCampaign)
}
}
self.tableView.reloadData()
}
......
......@@ -2977,6 +2977,8 @@ public class swiftApi {
public func setSeasonalList(_ seasonalCoupons: Array<LoyaltyGiftsForYouPackage>) {
GlobalVariables.seasonalList = seasonalCoupons
SwiftEventBus.post("seasonals_retrieved")
}
......