Manos Chorianopoulos

fix new badge functionality

......@@ -21,16 +21,20 @@ import SwiftEventBus
public override func viewDidLoad() {
super.viewDidLoad()
print("=== gifts viewDidLoad invoked ===")
self.hidesBottomBarWhenPushed = true
var tempCampaigns:Array<swiftApi.CampaignItemModel> = []
if (seasonalList.count > 0) {
for seasonalItem in seasonalList {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = seasonalItem._title
newCampaign._logo_url = seasonalItem._imageUrl
newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
campaigns.append(newCampaign)
tempCampaigns.append(newCampaign)
}
}
......@@ -41,14 +45,16 @@ import SwiftEventBus
newCampaign._title = ccmsItem._title
newCampaign._logo_url = ccmsItem._imageUrl
newCampaign._ccms = ccmsItem
campaigns.append(newCampaign)
tempCampaigns.append(newCampaign)
}
}
}
if (loyaltyList.count > 0) {
campaigns = campaigns + loyaltyList
tempCampaigns = tempCampaigns + loyaltyList
}
campaigns = tempCampaigns
setBackButton()
setNavigationTitle("GIFTS for YOU", "bold")
......@@ -89,12 +95,22 @@ import SwiftEventBus
mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00)
}
// public override func viewWillAppear(_ animated: Bool) {
// super.viewWillAppear(animated)
// print("=== viewWillAppear invoked ===")
// self.refreshData()
// }
// MARK: - Functions
func refreshData() -> Void {
self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
var tempCampaigns:Array<swiftApi.CampaignItemModel> = []
self.campaigns = []
self.seasonalList = swiftApi().getSeasonalList()
self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns()
self.loyaltyList = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
if (self.seasonalList.count > 0) {
for seasonalItem in self.seasonalList {
......@@ -102,7 +118,7 @@ import SwiftEventBus
newCampaign._title = seasonalItem._title
newCampaign._logo_url = seasonalItem._imageUrl
newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
self.campaigns.append(newCampaign)
tempCampaigns.append(newCampaign)
}
}
......@@ -113,15 +129,16 @@ import SwiftEventBus
newCampaign._title = ccmsItem._title
newCampaign._logo_url = ccmsItem._imageUrl
newCampaign._ccms = ccmsItem
self.campaigns.append(newCampaign)
tempCampaigns.append(newCampaign)
}
}
}
if (self.loyaltyList.count > 0) {
self.campaigns = self.campaigns + self.loyaltyList
tempCampaigns = tempCampaigns + self.loyaltyList
}
self.campaigns = tempCampaigns
self.tableView.reloadData()
}
......@@ -173,9 +190,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
vc.ccms = campaigns[indexPath.row]._ccms
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
......@@ -190,9 +207,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
vc.campaign = campaigns[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
......@@ -225,9 +242,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
......@@ -284,9 +301,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else {
let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
......
......@@ -13,15 +13,20 @@ import SwiftEventBus
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
public var campaigns:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
public var campaigns:Array<swiftApi.CampaignItemModel> = []
public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns()
public override func viewDidLoad() {
super.viewDidLoad()
print("=== mfy viewDidLoad invoked ===")
self.hidesBottomBarWhenPushed = true
var tempCampaigns:Array<swiftApi.CampaignItemModel> = loyaltyList
if (ccmsList.count > 0) {
for ccmsItem in ccmsList {
if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_MORE4U")) {
......@@ -31,10 +36,12 @@ import SwiftEventBus
newCampaign._subtitle = ccmsItem._subtitle
newCampaign._message = ccmsItem._message
newCampaign._ccms = ccmsItem
campaigns.append(newCampaign)
tempCampaigns.append(newCampaign)
}
}
}
campaigns = tempCampaigns
setBackButton()
setNavigationTitle("MORE for YOU", "bold")
......@@ -44,14 +51,12 @@ import SwiftEventBus
SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in
print("===== SwiftEventBus ccms_retrieved =====")
self.campaigns = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
self.tableView.reloadData()
self.refreshData()
}
SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in
print("===== SwiftEventBus campaigns_retrieved =====")
self.campaigns = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
self.tableView.reloadData()
self.refreshData()
}
tableView.clipsToBounds = true
......@@ -66,6 +71,30 @@ import SwiftEventBus
mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00)
}
// MARK: - Functions
func refreshData() -> Void {
self.loyaltyList = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns()
var tempCampaigns:Array<swiftApi.CampaignItemModel> = loyaltyList
if (self.ccmsList.count > 0) {
for ccmsItem in self.ccmsList {
if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_MORE4U")) {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = ccmsItem._title
newCampaign._logo_url = ccmsItem._imageUrl
newCampaign._subtitle = ccmsItem._subtitle
newCampaign._message = ccmsItem._message
newCampaign._ccms = ccmsItem
tempCampaigns.append(newCampaign)
}
}
}
self.campaigns = tempCampaigns
self.tableView.reloadData()
}
}
......@@ -115,9 +144,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
vc.ccms = campaigns[indexPath.row]._ccms
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
......@@ -132,9 +161,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
vc.campaign = campaigns[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
}
......@@ -166,9 +195,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
......@@ -231,9 +260,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaigns[indexPath.row].session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
......
......@@ -4941,9 +4941,9 @@ public class swiftApi {
vc.campaign = campaign
controller.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaign.session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
......@@ -4958,9 +4958,9 @@ public class swiftApi {
vc.params = swiftApi().constructCampaignParams(campaign)
controller.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = campaign.session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
func getSingleCampaignAsyncRequest(sessionUuid: String) {
......@@ -5003,9 +5003,9 @@ public class swiftApi {
vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms)
controller.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = loyaltyCampaign.session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = loyaltyCampaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
} else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) {
......@@ -5016,9 +5016,9 @@ public class swiftApi {
vc.campaign = loyaltyCampaign
controller.navigationController?.pushViewController(vc, animated: true)
// if let sessionUuid = loyaltyCampaign.session_uuid {
// getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
// }
if let sessionUuid = loyaltyCampaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
......