Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arthurpalves/53d6ee5477fa9a7a44e37a9706ee5238 to your computer and use it in GitHub Desktop.
Save arthurpalves/53d6ee5477fa9a7a44e37a9706ee5238 to your computer and use it in GitHub Desktop.
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