fix: load WorldStore on direct /hunt navigation

HuntPageComponent never called WorldStore.load(), so opening /hunt
directly (bookmark/hard refresh) without first visiting /world left
currentLocation() at null forever, stranding the page and the context
panel on their empty states with no recovery. Add ngOnInit that calls
worldStore.load() only when no location is present yet, mirroring
WorldPageComponent's existing call and avoiding a duplicate request.
This commit is contained in:
Bastian Wagner
2026-08-19 14:33:15 +02:00
parent 4e684dc45e
commit 26909d7e2a
2 changed files with 22 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
import { Component, inject } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { Router } from '@angular/router';
import { EncounterCardComponent } from '../encounter-card/encounter-card.component';
import { HuntingStore } from '../hunting.store';
@@ -10,11 +10,17 @@ import { WorldStore } from '../../world/world.store';
templateUrl: './hunt-page.component.html',
styleUrl: './hunt-page.component.scss',
})
export class HuntPageComponent {
export class HuntPageComponent implements OnInit {
protected readonly worldStore = inject(WorldStore);
protected readonly huntingStore = inject(HuntingStore);
private readonly router = inject(Router);
ngOnInit(): void {
if (this.worldStore.currentLocation() === null) {
void this.worldStore.load();
}
}
protected startHunt(): void {
void this.huntingStore.startHunt();
}