Manos Chorianopoulos

fix dublicate seasonals ata giftsVC

......@@ -53,55 +53,23 @@ 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()
self.refreshData()
if (self.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()
self.refreshData()
if (self.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()
self.refreshData()
if (self.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()
}
tableView.clipsToBounds = true
......@@ -117,6 +85,37 @@ import SwiftEventBus
}
// MARK: - Functions
func refreshData() -> Void {
self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
self.seasonalList = swiftApi().getSeasonalList()
self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns()
if (self.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)
}
}
if (self.ccmsList.count > 0) {
for ccmsItem in self.ccmsList {
if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_GIFTS4U")) {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = ccmsItem._title
newCampaign._logo_url = ccmsItem._imageUrl
newCampaign._ccms = ccmsItem
self.campaigns.append(newCampaign)
}
}
}
self.tableView.reloadData()
}
}
// MARK: - TableView
......