Datenschutz vollmacht fixed, two time counter added
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Navigation-History über location.state.
|
||||
* Jeder Link fügt die aktuelle URL zum Stack hinzu.
|
||||
* Der Zurück-Button poppt den letzten Eintrag und gibt den Rest weiter.
|
||||
*/
|
||||
|
||||
export interface NavState {
|
||||
history?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt den state für einen Link - fügt die aktuelle URL zum History-Stack hinzu.
|
||||
*/
|
||||
export function pushHistory(currentPath: string, locationState?: unknown): NavState {
|
||||
const prev = (locationState as NavState)?.history || [];
|
||||
return { history: [...prev, currentPath] };
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die Zurück-URL und den verbleibenden History-Stack zurück.
|
||||
*/
|
||||
export function popHistory(locationState?: unknown, fallback?: string): { to: string; state: NavState } {
|
||||
const history = [...((locationState as NavState)?.history || [])];
|
||||
const to = history.pop() || fallback || '/';
|
||||
return { to, state: { history } };
|
||||
}
|
||||
Reference in New Issue
Block a user