feat: Improving page loading

This commit is contained in:
2025-11-20 20:17:52 +03:00
parent 6f32c6e671
commit 85c71563c1
17 changed files with 545 additions and 273 deletions

View File

@@ -86,28 +86,35 @@ class EditSightStore {
}
hasLoadedCommon = false;
isLoading = false;
getSightInfo = async (id: number, language: Language) => {
const response = await languageInstance(language).get(`/sight/${id}`);
const data = response.data;
this.isLoading = true;
try {
const response = await languageInstance(language).get(`/sight/${id}`);
const data = response.data;
if (data.left_article != 0 && data.left_article != null) {
await this.getLeftArticle(data.left_article);
}
if (data.left_article != 0 && data.left_article != null) {
await this.getLeftArticle(data.left_article);
}
runInAction(() => {
this.sight[language] = {
...this.sight[language],
...data,
};
if (!this.hasLoadedCommon) {
this.sight.common = {
...this.sight.common,
runInAction(() => {
this.sight[language] = {
...this.sight[language],
...data,
};
this.hasLoadedCommon = true;
}
});
if (!this.hasLoadedCommon) {
this.sight.common = {
...this.sight.common,
...data,
};
this.hasLoadedCommon = true;
}
});
} finally {
this.isLoading = false;
}
};
updateLeftInfo = (language: Language, heading: string, body: string) => {
@@ -168,6 +175,8 @@ class EditSightStore {
clearSightInfo = () => {
this.needLeaveAgree = false;
this.hasLoadedCommon = false;
this.isLoading = false;
this.sight = {
common: {
id: 0,

View File

@@ -3,3 +3,4 @@ export * from "./BackButton";
export * from "./Modal";
export * from "./CoordinatesInput";
export * from "./AnimatedCircleButton";
export * from "./LoadingSpinner";