mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-13 16:53:29 +01:00
[AltWidget] Fixes incorrect days until expiration
Previously, we used Date() to calculate the number of days until apps expired. This meant all calculations were based on when the widget extension was run — not when it was actually displayed. As a result, this made it seem like the widget never updated since all timeline entries were calculated from the same date. Now, we instead calculate remaining days from AppEntry.date. This means the widget’s remaining days are relative to the current timeline entry’s date, matching what is displayed in AltStore.
This commit is contained in:
@@ -11,15 +11,16 @@ import WidgetKit
|
||||
|
||||
struct Countdown: View
|
||||
{
|
||||
let startDate: Date?
|
||||
let endDate: Date?
|
||||
var startDate: Date?
|
||||
var endDate: Date?
|
||||
var currentDate: Date = Date()
|
||||
|
||||
@Environment(\.font) private var font
|
||||
|
||||
private var numberOfDays: Int {
|
||||
guard let date = self.endDate else { return 0 }
|
||||
|
||||
let numberOfDays = date.numberOfCalendarDays(since: Date())
|
||||
let numberOfDays = date.numberOfCalendarDays(since: self.currentDate)
|
||||
return numberOfDays
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user