Showing
1 changed file
with
19 additions
and
11 deletions
| ... | @@ -23,6 +23,16 @@ import SwiftEventBus | ... | @@ -23,6 +23,16 @@ import SwiftEventBus | 
| 23 | 23 | ||
| 24 | self.hidesBottomBarWhenPushed = true | 24 | self.hidesBottomBarWhenPushed = true | 
| 25 | 25 | ||
| 26 | + SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in | ||
| 27 | + | ||
| 28 | + DispatchQueue.main.async { | ||
| 29 | + self.coupons = swiftApi().getCouponList() | ||
| 30 | + self.tableView.reloadData() | ||
| 31 | + | ||
| 32 | + self.handleEmptyView() | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 26 | getCouponsRequest() | 36 | getCouponsRequest() | 
| 27 | 37 | ||
| 28 | setBackButton() | 38 | setBackButton() | 
| ... | @@ -50,6 +60,13 @@ import SwiftEventBus | ... | @@ -50,6 +60,13 @@ import SwiftEventBus | 
| 50 | self.coupons = swiftApi().getCouponList() | 60 | self.coupons = swiftApi().getCouponList() | 
| 51 | self.tableView.reloadData() | 61 | self.tableView.reloadData() | 
| 52 | 62 | ||
| 63 | + self.handleEmptyView() | ||
| 64 | + | ||
| 65 | + self.navigationController?.hideHairline() | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + // MARK: - Functions | ||
| 69 | + func handleEmptyView() { | ||
| 53 | if (self.coupons.count == 0) { | 70 | if (self.coupons.count == 0) { | 
| 54 | self.emptyView.isHidden = false | 71 | self.emptyView.isHidden = false | 
| 55 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | 72 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | 
| ... | @@ -57,11 +74,8 @@ import SwiftEventBus | ... | @@ -57,11 +74,8 @@ import SwiftEventBus | 
| 57 | self.emptyView.isHidden = true | 74 | self.emptyView.isHidden = true | 
| 58 | self.emptyViewHeight.constant = 0 | 75 | self.emptyViewHeight.constant = 0 | 
| 59 | } | 76 | } | 
| 60 | - | ||
| 61 | - self.navigationController?.hideHairline() | ||
| 62 | } | 77 | } | 
| 63 | 78 | ||
| 64 | - | ||
| 65 | // MARK: - API Functions | 79 | // MARK: - API Functions | 
| 66 | func getCouponsRequest() { | 80 | func getCouponsRequest() { | 
| 67 | swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in | 81 | swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in | 
| ... | @@ -77,15 +91,9 @@ import SwiftEventBus | ... | @@ -77,15 +91,9 @@ import SwiftEventBus | 
| 77 | 91 | ||
| 78 | DispatchQueue.main.async { | 92 | DispatchQueue.main.async { | 
| 79 | SwiftEventBus.post("coupons_fetched") | 93 | SwiftEventBus.post("coupons_fetched") | 
| 80 | - self.tableView.reloadData() | 94 | + // self.tableView.reloadData() | 
| 81 | 95 | ||
| 82 | - if (self.coupons.count == 0) { | 96 | + // self.handleEmptyView() | 
| 83 | - self.emptyView.isHidden = false | ||
| 84 | - self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | ||
| 85 | - } else { | ||
| 86 | - self.emptyView.isHidden = true | ||
| 87 | - self.emptyViewHeight.constant = 0 | ||
| 88 | - } | ||
| 89 | } | 97 | } | 
| 90 | } else { | 98 | } else { | 
| 91 | self.coupons = [] | 99 | self.coupons = [] | ... | ... | 
- 
Please register or login to post a comment
