This commit is contained in:
scigward 2025-08-21 14:45:39 +03:00 committed by GitHub
parent 7ce58a2d14
commit 513743ca04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,7 @@ import SwiftUI
struct AnilistMatchPopupView: View {
let seriesTitle: String
let onSelect: (Int, String) -> Void
let onSelect: (Int, String, Int?) -> Void // id, title, malId
@State private var results: [[String: Any]] = []
@State private var isLoading = true
@ -54,7 +54,9 @@ struct AnilistMatchPopupView: View {
Button(action: {
if let id = result["id"] as? Int {
let title = result["title"] as? String ?? seriesTitle
onSelect(id, title)
let malId = result["mal_id"] as? Int
Logger.shared.log("Selected AniList ID: \(id), MAL ID: \(malId?.description ?? "nil")", type: "AnilistMatch")
onSelect(id, title, malId)
dismiss()
}
}) {
@ -86,6 +88,11 @@ struct AnilistMatchPopupView: View {
.font(.caption)
.foregroundStyle(.secondary)
}
if let malId = result["mal_id"] as? Int {
Text("MAL ID: \(malId)")
.font(.caption2)
.foregroundStyle(.secondary)
}
}
Spacer()
@ -153,7 +160,8 @@ struct AnilistMatchPopupView: View {
Button("Cancel", role: .cancel) { }
Button("Save") {
if let idInt = Int(manualIDText.trimmingCharacters(in: .whitespaces)) {
onSelect(idInt, seriesTitle)
Logger.shared.log("Manual AniList ID: \(idInt), MAL ID: nil", type: "AnilistMatch")
onSelect(idInt, seriesTitle, nil)
dismiss()
}
}
@ -205,6 +213,7 @@ struct AnilistMatchPopupView: View {
let cover = (media["coverImage"] as? [String: Any])?["large"] as? String
return [
"id": media["id"] ?? 0,
"mal_id": media["idMal"] as? Int ?? 0,
"title": titleInfo?["romaji"] ?? "Unknown",
"title_english": titleInfo?["english"] as Any,
"cover": cover as Any
@ -213,4 +222,4 @@ struct AnilistMatchPopupView: View {
}
}.resume()
}
}
}