Fix recursive link history updates for picture viewer

This commit is contained in:
2024-09-30 14:42:29 +02:00
parent bb953a6139
commit a00a85a56a
3 changed files with 8 additions and 3 deletions

View File

@ -137,7 +137,12 @@ document.addEventListener("alpine:init", () => {
this.current_picture = this.pictures.find(
(i) => i.id === first_picture_id,
);
this.$watch("current_picture", () => this.update_picture());
this.$watch("current_picture", (current, previous) => {
if (current === previous){ /* Avoid recursive updates */
return;
}
this.update_picture();
});
window.addEventListener("popstate", async (event) => {
if (!event.state || event.state.sas_picture_id === undefined) {
return;