You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-08 23:07:06 +02:00
feat(mobile): cache latest ios widget entry for fallback (#19824)
* cache the last image an ios widget fetched and use if a fetch fails in a future timeline build * code review fixes * downgrade pbx for flutter * use cache in snapshots
This commit is contained in:
@ -1,27 +1,6 @@
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct ImageEntry: TimelineEntry {
|
||||
let date: Date
|
||||
var image: UIImage?
|
||||
var subtitle: String? = nil
|
||||
var error: WidgetError? = nil
|
||||
var deepLink: URL? = nil
|
||||
|
||||
// Resizes the stored image to a maximum width of 450 pixels
|
||||
mutating func resize() {
|
||||
if (image == nil || image!.size.height < 450 || image!.size.width < 450 ) {
|
||||
return
|
||||
}
|
||||
|
||||
image = image?.resized(toWidth: 450)
|
||||
|
||||
if image == nil {
|
||||
error = .unableToResize
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ImmichWidgetView: View {
|
||||
var entry: ImageEntry
|
||||
|
||||
@ -29,7 +8,7 @@ struct ImmichWidgetView: View {
|
||||
if entry.image == nil {
|
||||
VStack {
|
||||
Image("LaunchImage")
|
||||
Text(entry.error?.errorDescription ?? "")
|
||||
Text(entry.metadata.error?.errorDescription ?? "")
|
||||
.minimumScaleFactor(0.25)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundStyle(.secondary)
|
||||
@ -44,7 +23,7 @@ struct ImmichWidgetView: View {
|
||||
)
|
||||
VStack {
|
||||
Spacer()
|
||||
if let subtitle = entry.subtitle {
|
||||
if let subtitle = entry.metadata.subtitle {
|
||||
Text(subtitle)
|
||||
.foregroundColor(.white)
|
||||
.padding(8)
|
||||
@ -55,7 +34,7 @@ struct ImmichWidgetView: View {
|
||||
}
|
||||
.padding(16)
|
||||
}
|
||||
.widgetURL(entry.deepLink)
|
||||
.widgetURL(entry.metadata.deepLink)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,7 +49,9 @@ struct ImmichWidgetView: View {
|
||||
ImageEntry(
|
||||
date: date,
|
||||
image: UIImage(named: "ImmichLogo"),
|
||||
subtitle: "1 year ago"
|
||||
metadata: EntryMetadata(
|
||||
subtitle: "1 year ago"
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user