<commit_before>//
//  OffrzDataSource.swift
//  Client
//
//  Created by Sahakyan on 12/5/17.
//  Copyright © 2017 Mozilla. All rights reserved.
//

import Foundation

class OffrzDataSource {
	
	private var currentOffr: Offr?
	private static let LastSeenOffrID = "LastSeenOffrID"

	var myOffrz = [Offr]()

	init() {
		self.updateMyOffrzList()
	}

	func getCurrentOffr() -> Offr? {
		if let o = self.currentOffr,
			self.isExpiredOffr(o) {
			self.currentOffr = nil
			// TODO: Impl notify on currentOffr change....
			self.updateMyOffrzList()
		}
		return self.currentOffr
	}

	func shouldShowOffrz() -> Bool {
		return SettingsPrefs.shared.getRegionPref() == "DE"
	}
	
	func hasUnseenOffrz() -> Bool {
		return !(self.currentOffr?.isSeen ?? true)
	}

	func markCurrentOffrSeen() {
		self.currentOffr?.isSeen = true
		LocalDataStore.setObject(self.currentOffr?.uid, forKey: OffrzDataSource.LastSeenOffrID)
	}

    func hasOffrz() -> Bool {
        return false
    }
    
    func shouldShowOnBoarding() -> Bool {
        return true
    }
    
    func hideOnBoarding() {
        
    }
    
	private func updateMyOffrzList() {<commit_msg>Onboarding settings config<commit_after>//
//  OffrzDataSource.swift
//  Client
//
//  Created by Sahakyan on 12/5/17.
//  Copyright © 2017 Mozilla. All rights reserved.
//

import Foundation

class OffrzDataSource {
	
	private var currentOffr: Offr?
	private static let LastSeenOffrID = "LastSeenOffrID"
	private static let OffrzOnboardingKey = "OffrzOnboardingNeeded"

	var myOffrz = [Offr]()

	init() {
		self.updateMyOffrzList()
	}

	func getCurrentOffr() -> Offr? {
		if let o = self.currentOffr,
			self.isExpiredOffr(o) {
			self.currentOffr = nil
			// TODO: Impl notify on currentOffr change....
			self.updateMyOffrzList()
		}
		return self.currentOffr
	}

	func shouldShowOffrz() -> Bool {
		return SettingsPrefs.shared.getRegionPref() == "DE"
	}
	
	func hasUnseenOffrz() -> Bool {
		return !(self.currentOffr?.isSeen ?? true)
	}

	func markCurrentOffrSeen() {
		self.currentOffr?.isSeen = true
		LocalDataStore.setObject(self.currentOffr?.uid, forKey: OffrzDataSource.LastSeenOffrID)
	}

    func hasOffrz() -> Bool {
        return self.getCurrentOffr() != nil
    }
    
    func shouldShowOnBoarding() -> Bool {
		guard let v = LocalDataStore.objectForKey(OffrzDataSource.OffrzOnboardingKey) as? Bool
			else {
			return true
		}
        return v
    }
    
    func hideOnBoarding() {
		LocalDataStore.setObject(false, forKey: OffrzDataSource.OffrzOnboardingKey)
    }
    
	private func updateMyOffrzList() {
{'fraction_non_alphanumeric': 0.11306042884990253, 'fraction_numerical': 0.007017543859649123, 'mean_word_length': 3.132045088566828, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6346322', 'n_tokens_mistral': 975, 'n_tokens_neox': 884, 'n_words': 192}