Skip to content

Commit

Permalink
Lower the widget reload time interval
Browse files Browse the repository at this point in the history
  • Loading branch information
literally-anything committed Jul 2, 2024
1 parent 19e12d1 commit abd90c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct WidgetDetailsAppIntentTimelineProvider: AppIntentTimelineProvider {
func timeline(for configuration: WidgetDetailsAppIntent, in context: Context) async -> Timeline<Entry> {
do {
let snapshot = try await entry(for: configuration, in: context)
Current.Log.debug("Reloading gauge widget")
return .init(
entries: [snapshot],
policy: .after(
Expand All @@ -35,7 +34,7 @@ struct WidgetDetailsAppIntentTimelineProvider: AppIntentTimelineProvider {
entries: [placeholder(in: context)],
policy: .after(
Current.date()
.addingTimeInterval(WidgetDetailsDataSource.fastExpiration.converted(to: .seconds).value)
.addingTimeInterval(WidgetDetailsDataSource.expiration.converted(to: .seconds).value)
)
)
}
Expand Down Expand Up @@ -112,11 +111,7 @@ struct WidgetDetailsAppIntentTimelineProvider: AppIntentTimelineProvider {

enum WidgetDetailsDataSource {
static var expiration: Measurement<UnitDuration> {
.init(value: 2, unit: .hours)
}

static var fastExpiration: Measurement<UnitDuration> {
.init(value: 1, unit: .hours)
.init(value: 15, unit: .minutes)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct WidgetGaugeAppIntentTimelineProvider: AppIntentTimelineProvider {
func timeline(for configuration: WidgetGaugeAppIntent, in context: Context) async -> Timeline<Entry> {
do {
let snapshot = try await entry(for: configuration, in: context)
Current.Log.debug("Reloading gauge widget")
return .init(
entries: [snapshot],
policy: .after(
Expand All @@ -35,7 +34,7 @@ struct WidgetGaugeAppIntentTimelineProvider: AppIntentTimelineProvider {
entries: [placeholder(in: context)],
policy: .after(
Current.date()
.addingTimeInterval(WidgetGaugeDataSource.fastExpiration.converted(to: .seconds).value)
.addingTimeInterval(WidgetGaugeDataSource.expiration.converted(to: .seconds).value)
)
)
}
Expand Down Expand Up @@ -121,11 +120,7 @@ struct WidgetGaugeAppIntentTimelineProvider: AppIntentTimelineProvider {

enum WidgetGaugeDataSource {
static var expiration: Measurement<UnitDuration> {
.init(value: 2, unit: .hours)
}

static var fastExpiration: Measurement<UnitDuration> {
.init(value: 1, unit: .hours)
.init(value: 15, unit: .minutes)
}
}

Expand Down

0 comments on commit abd90c0

Please sign in to comment.