diff --git a/frontend/src/turbo/history-action.ts b/frontend/src/turbo/history-action.ts index 35b3ec9f9db2..2eae55e35f24 100644 --- a/frontend/src/turbo/history-action.ts +++ b/frontend/src/turbo/history-action.ts @@ -1,17 +1,19 @@ import { StreamActions, StreamElement } from '@hotwired/turbo'; export function registerHistoryAction() { - StreamActions.history = function historyStreamAction(this: StreamElement) { - const url = this.getAttribute("url"); - const method = this.getAttribute("method"); + StreamActions.history = function historyStreamAction(this:StreamElement) { + const url = this.getAttribute('url'); + const method = this.getAttribute('method'); switch (method) { - case "replace": - window.history.replaceState({ href: url }, "", url) + case 'replace': + window.history.replaceState({ href: url }, '', url); break; - case "push": - window.history.pushState({ href: url }, "", url) + case 'push': + window.history.pushState({ href: url }, '', url); break; + default: + throw new Error(`Unknown history method: ${method}`); } }; } diff --git a/frontend/src/turbo/setup.ts b/frontend/src/turbo/setup.ts index c32d609c2f58..9ab2093703bb 100644 --- a/frontend/src/turbo/setup.ts +++ b/frontend/src/turbo/setup.ts @@ -14,8 +14,8 @@ registerDialogStreamAction(); registerHistoryAction(); // Error handling when "Content missing" returned -document.addEventListener('turbo:frame-missing', (event: CustomEvent) => { - const { detail: { response, visit } } = event as { detail: { response: Response, visit: (url: string) => void } }; +document.addEventListener('turbo:frame-missing', (event:CustomEvent) => { + const { detail: { response, visit } } = event as { detail:{ response:Response, visit:(url:string) => void } }; event.preventDefault(); visit(response.url); });