Manos Chorianopoulos

fix my rewards supermarket deals tile count

......@@ -69,6 +69,7 @@ import SwiftEventBus
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
public var smCoupons:Array<swiftApi.CouponItemModel> = [] // swiftApi().getSMCouponList()
public var boxCoupons:Array<swiftApi.ActiveBoxCouponModel> = swiftApi().getActiveBoxCoupons()
var timerWallet: DispatchSourceTimer?
......@@ -114,6 +115,15 @@ import SwiftEventBus
}
}
SwiftEventBus.onBackgroundThread(self, name: "sm_coupons_fetched") { result in
DispatchQueue.main.async {
self.smCoupons = swiftApi().getSMCouponList()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
}
SwiftEventBus.onBackgroundThread(self, name: "vouchers_fetched") { result in
DispatchQueue.main.async {
......@@ -559,6 +569,7 @@ import SwiftEventBus
self.coupons = swiftApi().getCouponList()
// TODO: Uncomment when UnifiedCoupons will be shown again
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.smCoupons = swiftApi().getSMCouponList()
// TODO: Maybe add this
self.matchOldSMCoupons()
// <===
......@@ -756,7 +767,7 @@ import SwiftEventBus
self.showSpinner = true
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) {
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.smCoupons.count == 0 && self.coupons.count == 0) {
self.showActiveCouponsBanners = false
} else {
......@@ -766,7 +777,7 @@ import SwiftEventBus
} else {
self.showSpinner = false
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) {
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.smCoupons.count == 0 && self.coupons.count == 0) {
self.showActiveCouponsBanners = false
if (swiftApi().getShowVouchersBanner() == "null") {
......@@ -1393,7 +1404,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletActiveCouponsScrollTableViewCellId", for: indexPath) as! WalletActiveCouponsScrollTableViewCell
// cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count, boxCount: self.boxCoupons.count)
cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count, boxCount: 0)
let smCount = self.unifiedCoupons.count + self.smCoupons.count
cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: smCount, gfyCount: self.coupons.count, boxCount: 0)
cell.parent = self
return cell
......