fix fight selection
This commit is contained in:
parent
2275f0050d
commit
27b9b0785e
@ -42,6 +42,7 @@ query GetReportData($reportCode: String!) {
|
||||
endTime
|
||||
fights {
|
||||
id
|
||||
encounterID
|
||||
name
|
||||
startTime
|
||||
endTime
|
||||
@ -75,9 +76,7 @@ function localized_graphql_uri(string $language): string {
|
||||
return preg_replace('#https://[^/]+#', 'https://' . $host, GRAPHQL_URI);
|
||||
}
|
||||
|
||||
// Fight names must be stable regardless of language — always use the English endpoint.
|
||||
// Localization only matters for ability/player names in analysis.php.
|
||||
$ch = curl_init(GRAPHQL_URI);
|
||||
$ch = curl_init(localized_graphql_uri($language));
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $payload,
|
||||
@ -85,6 +84,7 @@ curl_setopt_array($ch, [
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $_SESSION['access_token'],
|
||||
'Accept-Language: ' . ($language === 'jp' ? 'ja' : $language),
|
||||
],
|
||||
CURLOPT_SSL_VERIFYPEER => !DEV_MODE,
|
||||
]);
|
||||
|
||||
@ -138,13 +138,24 @@
|
||||
return String(name ?? '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function currentFightName() {
|
||||
const fight = (window.App?.fights ?? []).find(f => f.id === window.App?.fightId);
|
||||
return normalizeFightName(fight?.name);
|
||||
function fightEncounterId(fight) {
|
||||
return parseInt(fight?.encounterID ?? fight?.encounterId ?? 0, 10) || 0;
|
||||
}
|
||||
|
||||
function isSameFightName(fight) {
|
||||
const name = currentFightName();
|
||||
function currentFight() {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -341,7 +352,7 @@
|
||||
let allSameReportFights = [];
|
||||
|
||||
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>';
|
||||
visible.forEach(f => {
|
||||
const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?');
|
||||
@ -410,7 +421,7 @@
|
||||
extReportCode = code;
|
||||
updateRefFflogsLink();
|
||||
|
||||
const visibleExt = fights.filter(isSameFightName);
|
||||
const visibleExt = fights.filter(isSameEncounter);
|
||||
refExtFightSelect.innerHTML = '<option value="">— Fight auswählen —</option>';
|
||||
visibleExt.forEach(f => {
|
||||
const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user