From 513743ca048b49d52cd1ab54b1aec9b333dc078f Mon Sep 17 00:00:00 2001 From: scigward <162128369+scigward@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:45:39 +0300 Subject: [PATCH] Update --- .../Matching/AnilistMatchView.swift | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Sora/Views/MediaInfoView/Matching/AnilistMatchView.swift b/Sora/Views/MediaInfoView/Matching/AnilistMatchView.swift index 80588c4..5fd2ebc 100644 --- a/Sora/Views/MediaInfoView/Matching/AnilistMatchView.swift +++ b/Sora/Views/MediaInfoView/Matching/AnilistMatchView.swift @@ -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() } -} +} \ No newline at end of file