High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat(mobile): ios widget deeplink to asset in app (#19510)
Brandon Wees64cc7239fe55
diff --git a/mobile/ios/WidgetExtension/EntryGenerators.swift b/mobile/ios/WidgetExtension/EntryGenerators.swiftindex 6c1e1d4118..81bcc2263e 100644--- a/mobile/ios/WidgetExtension/EntryGenerators.swift+++ b/mobile/ios/WidgetExtension/EntryGenerators.swift@@ -3,7 +3,7 @@ import WidgetKitfunc buildEntry(api: ImmichAPI,- asset: SearchResult,+ asset: Asset,dateOffset: Int,subtitle: String? = nil)@@ -15,7 +15,8 @@ func buildEntry(to: Date.now)!let image = try await api.fetchImage(asset: asset)- return ImageEntry(date: entryDate, image: image, subtitle: subtitle)++ return ImageEntry(date: entryDate, image: image, subtitle: subtitle, deepLink: asset.deepLink)}func generateRandomEntries(diff --git a/mobile/ios/WidgetExtension/ImageWidgetView.swift b/mobile/ios/WidgetExtension/ImageWidgetView.swiftindex 2c84acc074..a4bda9d845 100644--- a/mobile/ios/WidgetExtension/ImageWidgetView.swift+++ b/mobile/ios/WidgetExtension/ImageWidgetView.swift@@ -6,6 +6,7 @@ struct ImageEntry: TimelineEntry {var image: UIImage?var subtitle: String? = nilvar error: WidgetError? = nil+ var deepLink: URL? = nil// Resizes the stored image to a maximum width of 450 pixelsmutating func resize() {@@ -54,6 +55,7 @@ struct ImmichWidgetView: View {}.padding(16)}+ .widgetURL(entry.deepLink)}}}diff --git a/mobile/ios/WidgetExtension/ImmichAPI.swift b/mobile/ios/WidgetExtension/ImmichAPI.swiftindex 628c7311ee..65fc27be77 100644--- a/mobile/ios/WidgetExtension/ImmichAPI.swift+++ b/mobile/ios/WidgetExtension/ImmichAPI.swift@@ -43,9 +43,13 @@ enum AssetType: String, Codable {case other = "OTHER"}-struct SearchResult: Codable {+struct Asset: Codable {let id: Stringlet type: AssetType++ var deepLink: URL? {+ return URL(string: "immich://asset?id=\(id)")+ }}struct SearchFilters: Codable {@@ -56,7 +60,7 @@ struct SearchFilters: Codable {struct MemoryResult: Codable {let id: String- var assets: [SearchResult]+ var assets: [Asset]let type: Stringstruct MemoryData: Codable {@@ -127,7 +131,7 @@ class ImmichAPI {}func fetchSearchResults(with filters: SearchFilters) async throws- -> [SearchResult]+ -> [Asset]{// get URLguard@@ -147,7 +151,7 @@ class ImmichAPI {let (data, _) = try await URLSession.shared.data(for: request)// decode data- return try JSONDecoder().decode([SearchResult].self, from: data)+ return try JSONDecoder().decode([Asset].self, from: data)}func fetchMemory(for date: Date) async throws -> [MemoryResult] {@@ -172,7 +176,7 @@ class ImmichAPI {return try JSONDecoder().decode([MemoryResult].self, from: data)}- func fetchImage(asset: SearchResult) async throws(WidgetError) -> UIImage {+ func fetchImage(asset: Asset) async throws(WidgetError) -> UIImage {let thumbnailParams = [URLQueryItem(name: "size", value: "preview")]let assetEndpoint = "/assets/" + asset.id + "/thumbnail"