Manos Chorianopoulos

fix new badge functionality

...@@ -21,16 +21,20 @@ import SwiftEventBus ...@@ -21,16 +21,20 @@ import SwiftEventBus
21 21
22 public override func viewDidLoad() { 22 public override func viewDidLoad() {
23 super.viewDidLoad() 23 super.viewDidLoad()
24 +
25 + print("=== gifts viewDidLoad invoked ===")
24 26
25 self.hidesBottomBarWhenPushed = true 27 self.hidesBottomBarWhenPushed = true
26 28
29 + var tempCampaigns:Array<swiftApi.CampaignItemModel> = []
30 +
27 if (seasonalList.count > 0) { 31 if (seasonalList.count > 0) {
28 for seasonalItem in seasonalList { 32 for seasonalItem in seasonalList {
29 let newCampaign = swiftApi.CampaignItemModel() 33 let newCampaign = swiftApi.CampaignItemModel()
30 newCampaign._title = seasonalItem._title 34 newCampaign._title = seasonalItem._title
31 newCampaign._logo_url = seasonalItem._imageUrl 35 newCampaign._logo_url = seasonalItem._imageUrl
32 newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId 36 newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
33 - campaigns.append(newCampaign) 37 + tempCampaigns.append(newCampaign)
34 } 38 }
35 } 39 }
36 40
...@@ -41,14 +45,16 @@ import SwiftEventBus ...@@ -41,14 +45,16 @@ import SwiftEventBus
41 newCampaign._title = ccmsItem._title 45 newCampaign._title = ccmsItem._title
42 newCampaign._logo_url = ccmsItem._imageUrl 46 newCampaign._logo_url = ccmsItem._imageUrl
43 newCampaign._ccms = ccmsItem 47 newCampaign._ccms = ccmsItem
44 - campaigns.append(newCampaign) 48 + tempCampaigns.append(newCampaign)
45 } 49 }
46 } 50 }
47 } 51 }
48 52
49 if (loyaltyList.count > 0) { 53 if (loyaltyList.count > 0) {
50 - campaigns = campaigns + loyaltyList 54 + tempCampaigns = tempCampaigns + loyaltyList
51 } 55 }
56 +
57 + campaigns = tempCampaigns
52 58
53 setBackButton() 59 setBackButton()
54 setNavigationTitle("GIFTS for YOU", "bold") 60 setNavigationTitle("GIFTS for YOU", "bold")
...@@ -89,12 +95,22 @@ import SwiftEventBus ...@@ -89,12 +95,22 @@ import SwiftEventBus
89 mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00) 95 mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00)
90 96
91 } 97 }
98 +
99 + // public override func viewWillAppear(_ animated: Bool) {
100 + // super.viewWillAppear(animated)
101 +
102 + // print("=== viewWillAppear invoked ===")
103 +
104 + // self.refreshData()
105 + // }
92 106
93 // MARK: - Functions 107 // MARK: - Functions
94 func refreshData() -> Void { 108 func refreshData() -> Void {
95 - self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) 109 + var tempCampaigns:Array<swiftApi.CampaignItemModel> = []
110 + self.campaigns = []
96 self.seasonalList = swiftApi().getSeasonalList() 111 self.seasonalList = swiftApi().getSeasonalList()
97 self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns() 112 self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns()
113 + self.loyaltyList = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
98 114
99 if (self.seasonalList.count > 0) { 115 if (self.seasonalList.count > 0) {
100 for seasonalItem in self.seasonalList { 116 for seasonalItem in self.seasonalList {
...@@ -102,7 +118,7 @@ import SwiftEventBus ...@@ -102,7 +118,7 @@ import SwiftEventBus
102 newCampaign._title = seasonalItem._title 118 newCampaign._title = seasonalItem._title
103 newCampaign._logo_url = seasonalItem._imageUrl 119 newCampaign._logo_url = seasonalItem._imageUrl
104 newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId 120 newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
105 - self.campaigns.append(newCampaign) 121 + tempCampaigns.append(newCampaign)
106 } 122 }
107 } 123 }
108 124
...@@ -113,15 +129,16 @@ import SwiftEventBus ...@@ -113,15 +129,16 @@ import SwiftEventBus
113 newCampaign._title = ccmsItem._title 129 newCampaign._title = ccmsItem._title
114 newCampaign._logo_url = ccmsItem._imageUrl 130 newCampaign._logo_url = ccmsItem._imageUrl
115 newCampaign._ccms = ccmsItem 131 newCampaign._ccms = ccmsItem
116 - self.campaigns.append(newCampaign) 132 + tempCampaigns.append(newCampaign)
117 } 133 }
118 } 134 }
119 } 135 }
120 136
121 if (self.loyaltyList.count > 0) { 137 if (self.loyaltyList.count > 0) {
122 - self.campaigns = self.campaigns + self.loyaltyList 138 + tempCampaigns = tempCampaigns + self.loyaltyList
123 } 139 }
124 140
141 + self.campaigns = tempCampaigns
125 self.tableView.reloadData() 142 self.tableView.reloadData()
126 } 143 }
127 144
...@@ -173,9 +190,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -173,9 +190,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
173 vc.ccms = campaigns[indexPath.row]._ccms 190 vc.ccms = campaigns[indexPath.row]._ccms
174 self.navigationController?.pushViewController(vc, animated: true) 191 self.navigationController?.pushViewController(vc, animated: true)
175 192
176 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 193 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
177 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 194 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
178 - // } 195 + }
179 196
180 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { 197 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
181 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 198 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
...@@ -190,9 +207,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -190,9 +207,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
190 vc.campaign = campaigns[indexPath.row] 207 vc.campaign = campaigns[indexPath.row]
191 self.navigationController?.pushViewController(vc, animated: true) 208 self.navigationController?.pushViewController(vc, animated: true)
192 209
193 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 210 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
194 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 211 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
195 - // } 212 + }
196 break; 213 break;
197 } 214 }
198 } 215 }
...@@ -225,9 +242,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -225,9 +242,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
225 242
226 self.navigationController?.pushViewController(vc, animated: true) 243 self.navigationController?.pushViewController(vc, animated: true)
227 244
228 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 245 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
229 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 246 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
230 - // } 247 + }
231 248
232 break; 249 break;
233 } 250 }
...@@ -284,9 +301,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -284,9 +301,9 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
284 vc.params = params 301 vc.params = params
285 self.navigationController?.pushViewController(vc, animated: true) 302 self.navigationController?.pushViewController(vc, animated: true)
286 303
287 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 304 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
288 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 305 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
289 - // } 306 + }
290 307
291 } else { 308 } else {
292 let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent() 309 let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
......
...@@ -13,15 +13,20 @@ import SwiftEventBus ...@@ -13,15 +13,20 @@ import SwiftEventBus
13 @IBOutlet weak var mainView: UIView! 13 @IBOutlet weak var mainView: UIView!
14 @IBOutlet weak var tableView: UITableView! 14 @IBOutlet weak var tableView: UITableView!
15 15
16 - public var campaigns:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) 16 + public var campaigns:Array<swiftApi.CampaignItemModel> = []
17 + public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
17 public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns() 18 public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns()
18 19
19 20
20 public override func viewDidLoad() { 21 public override func viewDidLoad() {
21 super.viewDidLoad() 22 super.viewDidLoad()
22 23
24 + print("=== mfy viewDidLoad invoked ===")
25 +
23 self.hidesBottomBarWhenPushed = true 26 self.hidesBottomBarWhenPushed = true
24 27
28 + var tempCampaigns:Array<swiftApi.CampaignItemModel> = loyaltyList
29 +
25 if (ccmsList.count > 0) { 30 if (ccmsList.count > 0) {
26 for ccmsItem in ccmsList { 31 for ccmsItem in ccmsList {
27 if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_MORE4U")) { 32 if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_MORE4U")) {
...@@ -31,10 +36,12 @@ import SwiftEventBus ...@@ -31,10 +36,12 @@ import SwiftEventBus
31 newCampaign._subtitle = ccmsItem._subtitle 36 newCampaign._subtitle = ccmsItem._subtitle
32 newCampaign._message = ccmsItem._message 37 newCampaign._message = ccmsItem._message
33 newCampaign._ccms = ccmsItem 38 newCampaign._ccms = ccmsItem
34 - campaigns.append(newCampaign) 39 + tempCampaigns.append(newCampaign)
35 } 40 }
36 } 41 }
37 } 42 }
43 +
44 + campaigns = tempCampaigns
38 45
39 setBackButton() 46 setBackButton()
40 setNavigationTitle("MORE for YOU", "bold") 47 setNavigationTitle("MORE for YOU", "bold")
...@@ -44,14 +51,12 @@ import SwiftEventBus ...@@ -44,14 +51,12 @@ import SwiftEventBus
44 51
45 SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in 52 SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in
46 print("===== SwiftEventBus ccms_retrieved =====") 53 print("===== SwiftEventBus ccms_retrieved =====")
47 - self.campaigns = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) 54 + self.refreshData()
48 - self.tableView.reloadData()
49 } 55 }
50 56
51 SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in 57 SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in
52 print("===== SwiftEventBus campaigns_retrieved =====") 58 print("===== SwiftEventBus campaigns_retrieved =====")
53 - self.campaigns = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) 59 + self.refreshData()
54 - self.tableView.reloadData()
55 } 60 }
56 61
57 tableView.clipsToBounds = true 62 tableView.clipsToBounds = true
...@@ -66,6 +71,30 @@ import SwiftEventBus ...@@ -66,6 +71,30 @@ import SwiftEventBus
66 mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00) 71 mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00)
67 72
68 } 73 }
74 +
75 + // MARK: - Functions
76 + func refreshData() -> Void {
77 + self.loyaltyList = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
78 + self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns()
79 + var tempCampaigns:Array<swiftApi.CampaignItemModel> = loyaltyList
80 +
81 + if (self.ccmsList.count > 0) {
82 + for ccmsItem in self.ccmsList {
83 + if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_MORE4U")) {
84 + let newCampaign = swiftApi.CampaignItemModel()
85 + newCampaign._title = ccmsItem._title
86 + newCampaign._logo_url = ccmsItem._imageUrl
87 + newCampaign._subtitle = ccmsItem._subtitle
88 + newCampaign._message = ccmsItem._message
89 + newCampaign._ccms = ccmsItem
90 + tempCampaigns.append(newCampaign)
91 + }
92 + }
93 + }
94 +
95 + self.campaigns = tempCampaigns
96 + self.tableView.reloadData()
97 + }
69 98
70 } 99 }
71 100
...@@ -115,9 +144,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -115,9 +144,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
115 vc.ccms = campaigns[indexPath.row]._ccms 144 vc.ccms = campaigns[indexPath.row]._ccms
116 self.navigationController?.pushViewController(vc, animated: true) 145 self.navigationController?.pushViewController(vc, animated: true)
117 146
118 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 147 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
119 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 148 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
120 - // } 149 + }
121 150
122 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { 151 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
123 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 152 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
...@@ -132,9 +161,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -132,9 +161,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
132 vc.campaign = campaigns[indexPath.row] 161 vc.campaign = campaigns[indexPath.row]
133 self.navigationController?.pushViewController(vc, animated: true) 162 self.navigationController?.pushViewController(vc, animated: true)
134 163
135 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 164 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
136 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 165 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
137 - // } 166 + }
138 } 167 }
139 } 168 }
140 } 169 }
...@@ -166,9 +195,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -166,9 +195,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
166 195
167 self.navigationController?.pushViewController(vc, animated: true) 196 self.navigationController?.pushViewController(vc, animated: true)
168 197
169 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 198 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
170 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 199 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
171 - // } 200 + }
172 201
173 break; 202 break;
174 } 203 }
...@@ -231,9 +260,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -231,9 +260,9 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
231 vc.params = params 260 vc.params = params
232 self.navigationController?.pushViewController(vc, animated: true) 261 self.navigationController?.pushViewController(vc, animated: true)
233 262
234 - // if let sessionUuid = campaigns[indexPath.row].session_uuid { 263 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
235 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 264 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
236 - // } 265 + }
237 } 266 }
238 } 267 }
239 268
......
...@@ -4941,9 +4941,9 @@ public class swiftApi { ...@@ -4941,9 +4941,9 @@ public class swiftApi {
4941 vc.campaign = campaign 4941 vc.campaign = campaign
4942 controller.navigationController?.pushViewController(vc, animated: true) 4942 controller.navigationController?.pushViewController(vc, animated: true)
4943 4943
4944 - // if let sessionUuid = campaign.session_uuid { 4944 + if let sessionUuid = campaign.session_uuid {
4945 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 4945 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
4946 - // } 4946 + }
4947 4947
4948 break; 4948 break;
4949 } 4949 }
...@@ -4958,9 +4958,9 @@ public class swiftApi { ...@@ -4958,9 +4958,9 @@ public class swiftApi {
4958 vc.params = swiftApi().constructCampaignParams(campaign) 4958 vc.params = swiftApi().constructCampaignParams(campaign)
4959 controller.navigationController?.pushViewController(vc, animated: true) 4959 controller.navigationController?.pushViewController(vc, animated: true)
4960 4960
4961 - // if let sessionUuid = campaign.session_uuid { 4961 + if let sessionUuid = campaign.session_uuid {
4962 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 4962 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
4963 - // } 4963 + }
4964 } 4964 }
4965 4965
4966 func getSingleCampaignAsyncRequest(sessionUuid: String) { 4966 func getSingleCampaignAsyncRequest(sessionUuid: String) {
...@@ -5003,9 +5003,9 @@ public class swiftApi { ...@@ -5003,9 +5003,9 @@ public class swiftApi {
5003 vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms) 5003 vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms)
5004 controller.navigationController?.pushViewController(vc, animated: true) 5004 controller.navigationController?.pushViewController(vc, animated: true)
5005 5005
5006 - // if let sessionUuid = loyaltyCampaign.session_uuid { 5006 + if let sessionUuid = loyaltyCampaign.session_uuid {
5007 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 5007 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
5008 - // } 5008 + }
5009 break; 5009 break;
5010 5010
5011 } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { 5011 } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) {
...@@ -5016,9 +5016,9 @@ public class swiftApi { ...@@ -5016,9 +5016,9 @@ public class swiftApi {
5016 vc.campaign = loyaltyCampaign 5016 vc.campaign = loyaltyCampaign
5017 controller.navigationController?.pushViewController(vc, animated: true) 5017 controller.navigationController?.pushViewController(vc, animated: true)
5018 5018
5019 - // if let sessionUuid = loyaltyCampaign.session_uuid { 5019 + if let sessionUuid = loyaltyCampaign.session_uuid {
5020 - // getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) 5020 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
5021 - // } 5021 + }
5022 break; 5022 break;
5023 5023
5024 } 5024 }
......