1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-08 23:07:06 +02:00

feat(mobile): ios widget deeplink to asset in app (#19510)

* feat: ios widget deeplinks to asset in app

* fix: casing

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Brandon Wees
2025-06-25 11:37:25 -05:00
committed by GitHub
parent 5f89c2d111
commit 64cc7239fe
3 changed files with 14 additions and 7 deletions

View File

@ -43,9 +43,13 @@ enum AssetType: String, Codable {
case other = "OTHER"
}
struct SearchResult: Codable {
struct Asset: Codable {
let id: String
let 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: String
struct MemoryData: Codable {
@ -127,7 +131,7 @@ class ImmichAPI {
}
func fetchSearchResults(with filters: SearchFilters) async throws
-> [SearchResult]
-> [Asset]
{
// get URL
guard
@ -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"