Manos Chorianopoulos

fix CouponsVC coupons reload

......@@ -23,6 +23,16 @@ import SwiftEventBus
self.hidesBottomBarWhenPushed = true
SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in
DispatchQueue.main.async {
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
self.handleEmptyView()
}
}
getCouponsRequest()
setBackButton()
......@@ -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,11 +74,8 @@ import SwiftEventBus
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
self.navigationController?.hideHairline()
}
// MARK: - API Functions
func getCouponsRequest() {
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in
......@@ -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 = []
......