mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(cockpit): the owner flags load at startup from one generated 15 KB sheet; the loading status names the place packs while they load on first lookup
This commit is contained in:
1 parent
63aa45c520
commit
5a6cf22be1
35 files changed
+643
-216
No files matched your search
@@ -8,8 +8,8 @@ import {
|
||||
tleAgeParts,
|
||||
} from '../../cockpitPresentation.js';
|
||||
import {
|
||||
loadFlagUrl,
|
||||
ownerMark,
|
||||
preloadOwnerFlags,
|
||||
regionName,
|
||||
shownOwnerMark,
|
||||
} from '../../ownerFlag.js';
|
||||
@@ -189,34 +189,25 @@ const placeText = computed(() => {
|
||||
const mark = computed(() =>
|
||||
ownerMark(orbital.value?.owner, { locale: getLocale() }),
|
||||
);
|
||||
const flagUrl = ref(null);
|
||||
// A flag that would not load (offline, a stale chunk after a deploy, a
|
||||
// missing file) falls back to the code as a badge, never to no owner at all.
|
||||
const flagFailed = ref(false);
|
||||
let flagRequest = 0;
|
||||
// The flag sheet loads at startup; a sheet that would not load (offline, a
|
||||
// stale asset after a deploy) is asked again for the next flag, and until it
|
||||
// comes the code shows as a badge, never no owner at all.
|
||||
const flagsReady = ref(false);
|
||||
const flagsFailed = ref(false);
|
||||
watch(
|
||||
() => (mark.value?.kind === 'flag' ? mark.value.code : null),
|
||||
async (code) => {
|
||||
const request = ++flagRequest;
|
||||
flagUrl.value = null;
|
||||
flagFailed.value = false;
|
||||
if (!code) return;
|
||||
let url = null;
|
||||
try {
|
||||
url = await loadFlagUrl(code);
|
||||
} catch {
|
||||
url = null;
|
||||
}
|
||||
if (request !== flagRequest) return;
|
||||
flagUrl.value = url;
|
||||
flagFailed.value = !url;
|
||||
if (!code || flagsReady.value) return;
|
||||
const ready = await preloadOwnerFlags();
|
||||
flagsReady.value = ready;
|
||||
flagsFailed.value = !ready;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
const shownMark = computed(() =>
|
||||
shownOwnerMark(mark.value, {
|
||||
url: flagUrl.value,
|
||||
failed: flagFailed.value,
|
||||
ready: flagsReady.value,
|
||||
failed: flagsFailed.value,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -293,8 +284,7 @@ const lensStyle = computed(() => {
|
||||
<div class="cockpit-orbital-readout">
|
||||
<p class="cockpit-orbital-kicker">{{ look.offset ? t('ORBITAL VIEW · OFF-NADIR') : t('ORBITAL VIEW · NADIR') }}</p>
|
||||
<div class="cockpit-orbital-title">
|
||||
<!-- i18n-ignore: @error is the image's load-failure event, not a status message. -->
|
||||
<img v-if="shownMark?.kind === 'flag'" class="cockpit-orbital-flag" :src="shownMark.url" :alt="shownMark.label" :title="shownMark.label" width="20" height="15" @error="flagFailed = true" />
|
||||
<span v-if="shownMark?.kind === 'flag'" class="cockpit-orbital-flag" role="img" :aria-label="shownMark.label" :title="shownMark.label" :style="shownMark.style"></span>
|
||||
<span v-else-if="shownMark?.kind === 'badge'" class="cockpit-orbital-owner-badge" :title="shownMark.title">{{ shownMark.label }}</span>
|
||||
<p class="cockpit-orbital-name">{{ orbital.name }}</p>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user