Improve MineGeo exploration and mapping features
This commit is contained in:
@@ -6,6 +6,11 @@ export type MapListing = {
|
||||
description: string;
|
||||
source: "plugin" | "fabric";
|
||||
state: string;
|
||||
parent_dataset_id: string | null;
|
||||
contribution_status: string | null;
|
||||
allow_contributions: boolean;
|
||||
contribution_server_address: string | null;
|
||||
update_state: string | null;
|
||||
bounds: { minX: number; minZ: number; maxX: number; maxZ: number };
|
||||
panorama_count: number;
|
||||
server_id: string;
|
||||
@@ -37,9 +42,19 @@ export async function catalog() {
|
||||
const servers = required(
|
||||
await client.from("catalog_servers").select("*"),
|
||||
) as { id: string; name: string; address: string | null }[];
|
||||
const owners = maps.length
|
||||
? required(
|
||||
await client
|
||||
.from("profiles")
|
||||
.select("id,display_name")
|
||||
.in("id", [...new Set(maps.map((m) => m.owner_id))]),
|
||||
)
|
||||
: [];
|
||||
return Promise.all(
|
||||
maps.map(async (m) => ({
|
||||
...m,
|
||||
credit:
|
||||
owners.find((p) => p.id === m.owner_id)?.display_name ?? "Explorer",
|
||||
image: (await mediaUrl(m.map_path || m.cover_path)) ?? undefined,
|
||||
mapImage: (await mediaUrl(m.map_path)) ?? undefined,
|
||||
server: servers.find((s) => s.id === m.server_id),
|
||||
@@ -55,8 +70,14 @@ export async function getMap(id: string) {
|
||||
.eq("state", "published")
|
||||
.single(),
|
||||
) as MapListing;
|
||||
const owner = await admin()
|
||||
.from("profiles")
|
||||
.select("display_name")
|
||||
.eq("id", map.owner_id)
|
||||
.maybeSingle();
|
||||
return {
|
||||
...map,
|
||||
credit: owner.data?.display_name ?? "Explorer",
|
||||
image: await mediaUrl(map.cover_path),
|
||||
mapImage: await mediaUrl(map.map_path),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user