mirror of
https://github.com/ae-utbm/sith.git
synced 2026-10-04 01:44:15 +00:00
Merge pull request #1499 from ae-utbm/sas-replacestate
don't push state on sas image change
This commit is contained in:
1 file changed
+5
-19
@@ -2,7 +2,6 @@ import type TomSelect from "tom-select";
|
|||||||
import type { TomOption } from "tom-select/src/types";
|
import type { TomOption } from "tom-select/src/types";
|
||||||
import type { UserAjaxSelect } from "#core:core/components/ajax-select-index";
|
import type { UserAjaxSelect } from "#core:core/components/ajax-select-index";
|
||||||
import { paginated } from "#core:utils/api";
|
import { paginated } from "#core:utils/api";
|
||||||
import { History } from "#core:utils/history";
|
|
||||||
import {
|
import {
|
||||||
type IdentifiedUserSchema,
|
type IdentifiedUserSchema,
|
||||||
type ModerationRequestSchema,
|
type ModerationRequestSchema,
|
||||||
@@ -228,11 +227,6 @@ document.addEventListener("alpine:init", () => {
|
|||||||
* Error message when a moderation operation fails
|
* Error message when a moderation operation fails
|
||||||
**/
|
**/
|
||||||
moderationError: "",
|
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() {
|
async init() {
|
||||||
this.pictures = (
|
this.pictures = (
|
||||||
@@ -267,12 +261,10 @@ document.addEventListener("alpine:init", () => {
|
|||||||
if (!event.state || event.state.sasPictureId === undefined) {
|
if (!event.state || event.state.sasPictureId === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.pushstate = History.Replace;
|
|
||||||
this.currentPicture = this.pictures.find(
|
this.currentPicture = this.pictures.find(
|
||||||
(i: PictureSchema) => i.id === Number.parseInt(event.state.sasPictureId, 10),
|
(i: PictureSchema) => i.id === Number.parseInt(event.state.sasPictureId, 10),
|
||||||
) as PictureWithIdentifications;
|
) as PictureWithIdentifications;
|
||||||
});
|
});
|
||||||
this.pushstate = History.Replace; /* Avoid first url push */
|
|
||||||
await this.updatePicture();
|
await this.updatePicture();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -285,17 +277,11 @@ document.addEventListener("alpine:init", () => {
|
|||||||
* the list of identified users are updated.
|
* the list of identified users are updated.
|
||||||
*/
|
*/
|
||||||
async updatePicture(): Promise<void> {
|
async updatePicture(): Promise<void> {
|
||||||
const updateArgs = {
|
window.history.replaceState(
|
||||||
data: { sasPictureId: this.currentPicture.id },
|
{ sasPictureId: this.currentPicture.id },
|
||||||
unused: "",
|
"",
|
||||||
url: this.currentPicture.sas_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.moderationError = "";
|
this.moderationError = "";
|
||||||
const index: number = this.pictures.indexOf(this.currentPicture);
|
const index: number = this.pictures.indexOf(this.currentPicture);
|
||||||
|
|||||||
Reference in new issue
Block a user