From ef1ff862a889a38d64159d568eeeafe05dd94d0e Mon Sep 17 00:00:00 2001 From: imperosol Date: Sun, 27 Sep 2026 19:26:02 +0200 Subject: [PATCH] don't push state on sas image change --- sas/static/bundled/sas/viewer-index.ts | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/sas/static/bundled/sas/viewer-index.ts b/sas/static/bundled/sas/viewer-index.ts index 6ae80fc7..320afb6b 100644 --- a/sas/static/bundled/sas/viewer-index.ts +++ b/sas/static/bundled/sas/viewer-index.ts @@ -2,7 +2,6 @@ import type TomSelect from "tom-select"; import type { TomOption } from "tom-select/src/types"; import type { UserAjaxSelect } from "#core:core/components/ajax-select-index"; import { paginated } from "#core:utils/api"; -import { History } from "#core:utils/history"; import { type IdentifiedUserSchema, type ModerationRequestSchema, @@ -228,11 +227,6 @@ document.addEventListener("alpine:init", () => { * Error message when a moderation operation fails **/ moderationError: "", - /** - * Method of pushing new url to the browser history - * Used by popstate event and always reset to it's default value when used - **/ - pushstate: History.Push, async init() { this.pictures = ( @@ -267,12 +261,10 @@ document.addEventListener("alpine:init", () => { if (!event.state || event.state.sasPictureId === undefined) { return; } - this.pushstate = History.Replace; this.currentPicture = this.pictures.find( (i: PictureSchema) => i.id === Number.parseInt(event.state.sasPictureId, 10), ) as PictureWithIdentifications; }); - this.pushstate = History.Replace; /* Avoid first url push */ await this.updatePicture(); }, @@ -285,17 +277,11 @@ document.addEventListener("alpine:init", () => { * the list of identified users are updated. */ async updatePicture(): Promise { - const updateArgs = { - data: { sasPictureId: this.currentPicture.id }, - unused: "", - url: this.currentPicture.sas_url, - }; - if (this.pushstate === History.Replace) { - window.history.replaceState(updateArgs.data, updateArgs.unused, updateArgs.url); - this.pushstate = History.Push; - } else { - window.history.pushState(updateArgs.data, updateArgs.unused, updateArgs.url); - } + window.history.replaceState( + { sasPictureId: this.currentPicture.id }, + "", + this.currentPicture.sas_url, + ); this.moderationError = ""; const index: number = this.pictures.indexOf(this.currentPicture);