fix fight selection

This commit is contained in:
Akurosia Kamo 2026-05-23 12:11:18 +02:00
parent 2275f0050d
commit 27b9b0785e
2 changed files with 21 additions and 10 deletions

View File

@ -42,6 +42,7 @@ query GetReportData($reportCode: String!) {
endTime endTime
fights { fights {
id id
encounterID
name name
startTime startTime
endTime endTime
@ -75,9 +76,7 @@ function localized_graphql_uri(string $language): string {
return preg_replace('#https://[^/]+#', 'https://' . $host, GRAPHQL_URI); return preg_replace('#https://[^/]+#', 'https://' . $host, GRAPHQL_URI);
} }
// Fight names must be stable regardless of language — always use the English endpoint. $ch = curl_init(localized_graphql_uri($language));
// Localization only matters for ability/player names in analysis.php.
$ch = curl_init(GRAPHQL_URI);
curl_setopt_array($ch, [ curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload, CURLOPT_POSTFIELDS => $payload,
@ -85,6 +84,7 @@ curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => [ CURLOPT_HTTPHEADER => [
'Content-Type: application/json', 'Content-Type: application/json',
'Authorization: Bearer ' . $_SESSION['access_token'], 'Authorization: Bearer ' . $_SESSION['access_token'],
'Accept-Language: ' . ($language === 'jp' ? 'ja' : $language),
], ],
CURLOPT_SSL_VERIFYPEER => !DEV_MODE, CURLOPT_SSL_VERIFYPEER => !DEV_MODE,
]); ]);

View File

@ -138,13 +138,24 @@
return String(name ?? '').trim().toLowerCase(); return String(name ?? '').trim().toLowerCase();
} }
function currentFightName() { function fightEncounterId(fight) {
const fight = (window.App?.fights ?? []).find(f => f.id === window.App?.fightId); return parseInt(fight?.encounterID ?? fight?.encounterId ?? 0, 10) || 0;
return normalizeFightName(fight?.name);
} }
function isSameFightName(fight) { function currentFight() {
const name = currentFightName(); return (window.App?.fights ?? []).find(f => f.id === window.App?.fightId) ?? null;
}
function isSameEncounter(fight) {
const selectedFight = currentFight();
const selectedEncounterId = fightEncounterId(selectedFight);
const encounterId = fightEncounterId(fight);
if (selectedEncounterId && encounterId) {
return encounterId === selectedEncounterId;
}
const name = normalizeFightName(selectedFight?.name);
return name !== '' && normalizeFightName(fight?.name) === name; return name !== '' && normalizeFightName(fight?.name) === name;
} }
@ -341,7 +352,7 @@
let allSameReportFights = []; let allSameReportFights = [];
function populateRefFightSelect() { function populateRefFightSelect() {
const visible = allSameReportFights.filter(f => f.id !== window.App.fightId && isSameFightName(f)); const visible = allSameReportFights.filter(f => f.id !== window.App.fightId && isSameEncounter(f));
refFightSelect.innerHTML = '<option value="">Kein Vergleich</option>'; refFightSelect.innerHTML = '<option value="">Kein Vergleich</option>';
visible.forEach(f => { visible.forEach(f => {
const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?'); const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?');
@ -410,7 +421,7 @@
extReportCode = code; extReportCode = code;
updateRefFflogsLink(); updateRefFflogsLink();
const visibleExt = fights.filter(isSameFightName); const visibleExt = fights.filter(isSameEncounter);
refExtFightSelect.innerHTML = '<option value="">— Fight auswählen —</option>'; refExtFightSelect.innerHTML = '<option value="">— Fight auswählen —</option>';
visibleExt.forEach(f => { visibleExt.forEach(f => {
const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?'); const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?');