Manos Chorianopoulos

filter segmented campaigns depending on badge

......@@ -2031,10 +2031,20 @@ public class swiftApi {
public func setCampaignList(_ campaigns: Array<CampaignItemModel>) -> Void {
let userTag = self.getUserTag()
var campaignsArray:Array<CampaignItemModel> = []
for item in campaigns {
if (((item._badge == nil) || (item._badge == ""))) {
campaignsArray.append(item)
} else if (item._badge == userTag) {
campaignsArray.append(item)
}
}
if ((userTag != nil) && (userTag != "")) {
GlobalVariables.campaigns = campaigns.filter { $0.offer_category != "questionnaire" }
GlobalVariables.campaigns = campaignsArray.filter { $0.offer_category != "questionnaire" }
} else {
GlobalVariables.campaigns = campaigns
GlobalVariables.campaigns = campaignsArray
}
}
......@@ -2165,11 +2175,20 @@ public class swiftApi {
public func setUniqueCampaignList(_ campaigns: Array<CampaignItemModel>) -> Void {
let userTag = self.getUserTag()
var campaignsArray:Array<CampaignItemModel> = []
for item in campaigns {
if (((item._badge == nil) || (item._badge == ""))) {
campaignsArray.append(item)
} else if (item._badge == userTag) {
campaignsArray.append(item)
}
}
if ((userTag != nil) && (userTag != "")) {
GlobalVariables.campaigns = campaigns.filter { $0.offer_category != "questionnaire" }
GlobalVariables.campaigns = campaignsArray.filter { $0.offer_category != "questionnaire" }
} else {
GlobalVariables.campaigns = campaigns
GlobalVariables.campaigns = campaignsArray
}
}
......