feat(#41): Resolve corporation names in CorporationLabel

This commit is contained in:
Sirttas committed 2026-07-26 20:57:05 +02:00
1 parent d4b48b05ee
commit d1237bf1d2
7 files changed
+326 -3

No files matched your search

+4 -1
View File
@@ -1,7 +1,10 @@
<script setup lang="ts">
import {Corporation} from "./corporations.ts";
interface Props {
corporationId: number;
corporation?: Corporation | null;
division?: number | null;
size?: number;
}
@@ -14,6 +17,6 @@ const props = withDefaults(defineProps<Props>(), {
<template>
<div class="flex">
<img class="me-2" :src="`https://images.evetech.net/corporations/${corporationId}/logo?size=${size}`" />
<span>Corporation<template v-if="division"> &middot; Division {{ division }}</template></span>
<span>{{ corporation?.name ?? 'Corporation' }}<template v-if="division"> &middot; Division {{ division }}</template></span>
</div>
</template>
+38
View File
@@ -0,0 +1,38 @@
import {corporationApi} from "@/mammon";
import {defineStore} from "pinia";
import {ref} from "vue";
import {CorporationResponse} from "@/generated/mammon";
export type Corporation = CorporationResponse
export const useCorporationsStore = defineStore('corporations', () => {
const corporations = ref<Record<number, Corporation | null>>({});
const inFlight = new Map<number, Promise<Corporation | undefined>>();
const findById = async (corporationId: number): Promise<Corporation | undefined> => {
const cached = corporations.value[corporationId];
if (cached !== undefined) {
return cached ?? undefined;
}
let request = inFlight.get(corporationId);
if (!request) {
request = corporationApi.findCorporation(corporationId)
.then(response => {
corporations.value[corporationId] = response.data;
return response.data;
})
.catch(() => {
corporations.value[corporationId] = null;
return undefined;
})
.finally(() => inFlight.delete(corporationId));
inFlight.set(corporationId, request);
}
return request;
}
return {corporations, findById};
})
+2
View File
@@ -1 +1,3 @@
export * from './corporations.ts'
export {default as CorporationLabel} from './CorporationLabel.vue';