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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user