Created
June 30, 2020 15:43
-
-
Save arthurpalves/53d6ee5477fa9a7a44e37a9706ee5238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func timeline(for configuration: MainAccountIntent, with context: Context, completion: @escaping (Timeline<Entry>) -> ()) { | |
let currentDate = Date() | |
let futureDate = Calendar.current.date(byAdding: .minute, value: 10, to: currentDate)! | |
viewModel.fetchProducts() { products in | |
guard let mainProduct = products.first(where: { $0.type == .main }) else { return } | |
let entry = AccountEntry(date: currentDate, | |
product: mainProduct, | |
maskSensitiveData: configuration.maskSensitiveData as? Bool ?? true) | |
let timeline = Timeline(entries: [entry], policy: .after(refreshDate)) | |
completion(timeline) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment