fix: resolve all remaining audit failures across rust, svelte, and java

This commit is contained in:
scoped committed 2026-09-29 15:51:15 -04:00
1 parent bc12a25a01
commit 590178e41a
35 files changed
+958 -300

No files matched your search

+23 -5
View File
@@ -22,6 +22,8 @@
onunclaim?: (claimId: number) => void;
} = $props();
let servers = $state<Array<{ id: number; name: string; instance_id: string }>>([]);
let serverId = $state<number | null>(null);
let dimension = $state<'minecraft:overworld' | 'minecraft:the_nether' | 'minecraft:the_end'>('minecraft:overworld');
let centerX = $state(0);
let centerZ = $state(0);
@@ -39,11 +41,14 @@
] as const;
async function loadClaims() {
if (!instanceId) return;
if (!instanceId || !serverId) { claims = []; return; }
loading = true;
try {
claims = await invoke<GuildClaim[]>('get_guild_claims', {
instanceId,
serverId,
centerX,
centerZ,
dimension
});
} catch (e: any) {
@@ -66,11 +71,13 @@
);
async function handleClaim() {
if (!selectedChunk || !myGuildId) return;
if (!selectedChunk || !myGuildId || !serverId) return;
claiming = true;
try {
const claim = await invoke<GuildClaim>('claim_guild_chunk', {
guildId: myGuildId,
instanceId,
serverId,
dimension,
chunkX: selectedChunk.x,
chunkZ: selectedChunk.z
@@ -112,17 +119,28 @@
}
$effect(() => {
if (instanceId && dimension) {
if (instanceId && dimension && serverId) {
loadClaims();
}
});
onMount(() => {
loadClaims();
onMount(async () => {
const result = await invoke<{ servers: typeof servers }>('get_public_servers');
servers = result.servers;
});
$effect(() => {
const available = servers.filter(s => s.instance_id === instanceId);
if (!available.some(s => s.id === serverId)) serverId = available[0]?.id ?? null;
});
</script>
<div class="chunk-map-container glass">
<label>Game server
<select bind:value={serverId}>
{#each servers.filter(s => s.instance_id === instanceId) as server}<option value={server.id}>{server.name}</option>{/each}
</select>
</label>
{#if !serverId}<p>Link a game server to this instance in the panel before claiming territory.</p>{/if}
<!-- Controls Bar -->
<div class="map-controls">
<div class="dim-selector">
@@ -54,7 +54,7 @@
savingProfile = true;
try {
profile = await invoke<UserProfileView>('update_my_profile', {
bio: editBio.trim() || null,
bio: editBio.trim(),
bannerUrl: editBanner.trim() || null
});
editing = false;
@@ -89,9 +89,8 @@
async function handleLikePost(post: UserPost) {
try {
const liked = await invoke<boolean>('like_user_post', { postId: post.id });
post.liked_by_me = liked;
post.likes_count = liked ? post.likes_count + 1 : Math.max(0, post.likes_count - 1);
await invoke('like_user_post', { postId: post.id });
post.likes_count += 1;
} catch (e: any) {
toast(e?.message ?? 'Failed to update like', 'error');
}
@@ -131,8 +130,8 @@
<div class="user-titles">
<div class="user-row">
<h2>{profile.username}</h2>
{#if profile.global_level?.title}
<span class="badge title-badge"><Award size={12} /> {profile.global_level.title}</span>
{#if profile.level_info?.title}
<span class="badge title-badge"><Award size={12} /> {profile.level_info.title}</span>
{/if}
</div>
<div class="meta-row tiny muted">
@@ -140,7 +139,7 @@
<span>•</span>
<span>{profile.friends_count} Friends</span>
<span>•</span>
<span class="global-lvl-tag">Level {profile.global_level?.level ?? 1}</span>
<span class="global-lvl-tag">Level {profile.level_info?.level ?? 1}</span>
</div>
</div>
</div>
@@ -195,7 +194,7 @@
<Award size={14} /> Levels & Ranks
</button>
<button class:active={activeTab === 'achievements'} onclick={() => (activeTab = 'achievements')}>
<Trophy size={14} /> Achievements ({profile.achievements.length})
<Trophy size={14} /> Achievements ({profile.achievements_count ?? profile.achievements?.length ?? 0})
</button>
<button class:active={activeTab === 'stats'} onclick={() => (activeTab = 'stats')}>
<Swords size={14} /> Stats
@@ -285,16 +284,16 @@
<h3>SCOPENET Global Level</h3>
</div>
<div class="level-pill">
Level {profile.global_level.level}
Level {profile.level_info.level}
</div>
</div>
<div class="xp-bar-wrap">
<div class="xp-numbers tiny">
<span>{profile.global_level.current_xp.toLocaleString()} XP</span>
<span>{profile.global_level.next_level_xp.toLocaleString()} XP</span>
<span>{profile.level_info.current_xp.toLocaleString()} XP</span>
<span>{profile.level_info.next_level_xp.toLocaleString()} XP</span>
</div>
<div class="xp-bar">
<div class="xp-fill" style:width="{profile.global_level.progress_pct}%"></div>
<div class="xp-fill" style:width="{profile.level_info.progress_pct}%"></div>
</div>
</div>
</div>