Manos Chorianopoulos

fix CouponsVC coupons reload

......@@ -22,6 +22,16 @@ import SwiftEventBus
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in
DispatchQueue.main.async {
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
self.handleEmptyView()
}
}
getCouponsRequest()
......@@ -50,6 +60,13 @@ import SwiftEventBus
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
self.handleEmptyView()
self.navigationController?.hideHairline()
}
// MARK: - Functions
func handleEmptyView() {
if (self.coupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
......@@ -57,10 +74,7 @@ import SwiftEventBus
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
self.navigationController?.hideHairline()
}
// MARK: - API Functions
func getCouponsRequest() {
......@@ -77,15 +91,9 @@ import SwiftEventBus
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
self.tableView.reloadData()
// self.tableView.reloadData()
if (self.coupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
// self.handleEmptyView()
}
} else {
self.coupons = []
......