mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
apply correct media prefixes
This commit is contained in:
1 parent
3c92ab3a19
commit
cca46957bc
4 files changed
+21
-7
No files matched your search
@@ -17,6 +17,8 @@ import type { Tiers } from "@protos/tiers";
|
|||||||
export abstract class AbstractAPI {
|
export abstract class AbstractAPI {
|
||||||
abstract metadata: MetadataAccessor;
|
abstract metadata: MetadataAccessor;
|
||||||
|
|
||||||
|
abstract mediaPrefix(path: string): string;
|
||||||
|
|
||||||
abstract tankList(): Promise<TankList>;
|
abstract tankList(): Promise<TankList>;
|
||||||
abstract tank(id: string): Promise<Tank>;
|
abstract tank(id: string): Promise<Tank>;
|
||||||
abstract tanks(): Promise<Tanks>;
|
abstract tanks(): Promise<Tanks>;
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ export class ClientAPI extends AbstractAPI {
|
|||||||
throw new Error("MetadataAccessor is inaccessible on the client");
|
throw new Error("MetadataAccessor is inaccessible on the client");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UnimplementedOnClient
|
||||||
|
mediaPrefix(): never {
|
||||||
|
throw rejected();
|
||||||
|
}
|
||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
tankList() {
|
tankList() {
|
||||||
return fetchPB("/api/tanks/list.pb", TankList);
|
return fetchPB("/api/tanks/list.pb", TankList);
|
||||||
|
|||||||
@@ -36,6 +36,16 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mediaPrefix(path: string) {
|
||||||
|
const config = this.resolveClientConfig();
|
||||||
|
const metroResources = config.MetroResources();
|
||||||
|
const remoteStorage = this.resolveRemoteUrl(
|
||||||
|
metroResources.remote_storage!.remote_urls,
|
||||||
|
);
|
||||||
|
|
||||||
|
return `${remoteStorage.url}/${remoteStorage.relative_path}${path}`;
|
||||||
|
}
|
||||||
|
|
||||||
resolveRemoteUrl(remoteUrls: string[]) {
|
resolveRemoteUrl(remoteUrls: string[]) {
|
||||||
let remoteStorage: RemoteStorageComponent | undefined = undefined;
|
let remoteStorage: RemoteStorageComponent | undefined = undefined;
|
||||||
|
|
||||||
@@ -380,12 +390,7 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
async currencyIcon(id: string) {
|
async currencyIcon(id: string) {
|
||||||
const item = this.metadata.item(`CurrencyEntity.${id}`);
|
const item = this.metadata.item(`CurrencyEntity.${id}`);
|
||||||
const stuffUI = item.StuffUI("UIComponent");
|
const stuffUI = item.StuffUI("UIComponent");
|
||||||
const config = this.resolveClientConfig();
|
|
||||||
const metroResources = config.MetroResources();
|
|
||||||
const remoteStorage = this.resolveRemoteUrl(
|
|
||||||
metroResources.remote_storage!.remote_urls,
|
|
||||||
);
|
|
||||||
|
|
||||||
return `${remoteStorage.url}/${remoteStorage.relative_path}${stuffUI.icon!.value}`;
|
return this.mediaPrefix(stuffUI.icon!.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,5 +12,7 @@ export { getStaticPaths } from "./[id].json";
|
|||||||
*/
|
*/
|
||||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||||
const avatar = await api.avatar(params.id);
|
const avatar = await api.avatar(params.id);
|
||||||
return await imageProxy(avatar.profile_avatar!.avatar);
|
return await imageProxy(
|
||||||
|
api.mediaPrefix(avatar.profile_avatar!.avatar!.value),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user