Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaus Zanders committed Jul 29, 2024
1 parent e3fc32c commit 9824cd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions frontend/src/turbo/history-action.ts
Original file line number Diff line number Diff line change
@@ -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}`);
}
};
}
4 changes: 2 additions & 2 deletions frontend/src/turbo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 9824cd2

Please sign in to comment.