(history: NavigationHistory<T>, entry: T, options: NavigationHistoryOptions<T>)
| 89 | * Schritt und kein Auffrischen: dann bleibt alles, wie es ist. |
| 90 | */ |
| 91 | export function refreshNavigation<T>(history: NavigationHistory<T>, entry: T, options: NavigationHistoryOptions<T>): NavigationHistory<T> { |
| 92 | const current = history.entries[history.index]; |
| 93 | if (current === undefined || current === entry || options.key(current) !== options.key(entry)) return history; |
| 94 | const entries = history.entries.map((item, at) => (at === history.index ? entry : item)); |
| 95 | const place = options.recentKey?.(entry); |
| 96 | const recent = place === undefined ? history.recent : history.recent.map((item) => (options.recentKey?.(item) === place ? entry : item)); |
| 97 | return { entries, index: history.index, recent }; |
| 98 | } |
| 99 | |
| 100 | /** Der Eintrag, zu dem Zurueck (-1) oder Vor (+1) fuehren wuerde. */ |
| 101 | export function peekNavigation<T>(history: NavigationHistory<T>, step: -1 | 1): T | undefined { |
no test coverage detected