Manos Chorianopoulos

ShareViewController CouponSharing optimizations

......@@ -284,18 +284,23 @@ import SwiftEventBus
DispatchQueue.main.async {
if (response?.getStatus == 1) {
self.showSuccessDialog("Συγχαρητήρια!","Μόλις έκανες δώρο ένα κουπόνι!")
if let tempCoupon = self.coupon {
swiftApi().removeCouponItem(couponArg: tempCoupon)
SwiftEventBus.post("coupons_fetched")
}
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
// swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
// func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
// if (couponsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
}
} else {
}
}
// DispatchQueue.main.async {
// SwiftEventBus.post("coupons_fetched")
// }
// } else {
// }
// }
} else if (response?.getStatus == 4) {
self.showDialog("Αποτυχία", response?.getMsg ?? "")
......
......@@ -9259,11 +9259,16 @@ public class swiftApi {
}
public func addCouponItem(newCoupon: CouponItemModel) {
var tempCouponList = getCouponList()
var tempCouponList = swiftApi().getCouponList()
tempCouponList.append(newCoupon)
swiftApi().setCouponList(tempCouponList)
}
public func removeCouponItem(couponArg: CouponItemModel) {
let tempCouponList = swiftApi().getCouponList().filter { $0.coupon != couponArg.coupon }
swiftApi().setCouponList(tempCouponList)
}
public func removeCampaignItem(campaignArg: CampaignItemModel) {
let allCampaigns = swiftApi().getAllCampaignList().filter { $0.session_uuid != campaignArg.session_uuid }
swiftApi().setUniqueCampaignList(allCampaigns)
......