Open last dialog on error

This commit is contained in:
Natsumi
2026-02-01 03:14:07 +13:00
committed by pa
parent 8f57fbb572
commit c86cf5e5ed
7 changed files with 99 additions and 44 deletions
+9 -2
View File
@@ -221,8 +221,11 @@ export const useAvatarStore = defineStore('Avatar', () => {
ref2.authorId !== userStore.currentUser.id
) {
D.loading = false;
uiStore.closeMainDialog();
return;
D.id = null;
D.visible = false;
uiStore.jumpBackDialogCrumb();
toast.error(t('message.api_handler.avatar_private_or_deleted'));
throw new Error('Avatar is private or deleted');
}
}
avatarRequest
@@ -263,6 +266,10 @@ export const useAvatarStore = defineStore('Avatar', () => {
})
.catch((err) => {
D.visible = false;
D.id = null;
D.visible = false;
uiStore.jumpBackDialogCrumb();
toast.error(t('message.api_handler.avatar_private_or_deleted'));
throw err;
})
.finally(() => {
+3 -1
View File
@@ -168,7 +168,9 @@ export const useGroupStore = defineStore('Group', () => {
})
.catch((err) => {
D.loading = false;
uiStore.closeMainDialog();
D.id = null;
D.visible = false;
uiStore.jumpBackDialogCrumb();
toast.error(t('message.group.load_failed'));
throw err;
})
+73 -1
View File
@@ -18,6 +18,11 @@ import { useWorldStore } from './world';
export const useUiStore = defineStore('Ui', () => {
const notificationStore = useNotificationStore();
const userStore = useUserStore();
const worldStore = useWorldStore();
const avatarStore = useAvatarStore();
const groupStore = useGroupStore();
const instanceStore = useInstanceStore();
const router = useRouter();
const keys = useMagicKeys();
const { directAccessPaste } = useSearchStore();
@@ -108,6 +113,71 @@ export const useUiStore = defineStore('Ui', () => {
dialogCrumbs.value.splice(index + 1);
}
function jumpBackDialogCrumb() {
if (dialogCrumbs.value.length > 1) {
dialogCrumbs.value.splice(dialogCrumbs.value.length - 1);
}
if (dialogCrumbs.value.length === 0) {
closeMainDialog();
return;
}
handleBreadcrumbClick(dialogCrumbs.value.length - 1);
}
function handleBreadcrumbClick(index) {
const item = dialogCrumbs.value[index];
if (!item) {
return;
}
jumpDialogCrumb(index);
if (item.type === 'user') {
userStore.showUserDialog(item.id, { skipBreadcrumb: true });
return;
}
if (item.type === 'world') {
worldStore.showWorldDialog(item.id, null, {
skipBreadcrumb: true
});
return;
}
if (item.type === 'avatar') {
avatarStore.showAvatarDialog(item.id, { skipBreadcrumb: true });
return;
}
if (item.type === 'group') {
groupStore.showGroupDialog(item.id, { skipBreadcrumb: true });
return;
}
if (item.type === 'previous-instances-user') {
instanceStore.showPreviousInstancesListDialog('user', item.id, {
skipBreadcrumb: true
});
return;
}
if (item.type === 'previous-instances-world') {
instanceStore.showPreviousInstancesListDialog('world', item.id, {
skipBreadcrumb: true
});
return;
}
if (item.type === 'previous-instances-group') {
instanceStore.showPreviousInstancesListDialog('group', item.id, {
skipBreadcrumb: true
});
return;
}
if (item.type === 'previous-instances-info') {
instanceStore.showPreviousInstancesInfoDialog(item.id, {
skipBreadcrumb: true
});
return;
}
console.error(
`Unknown dialog crumb type: ${item.type}, closing dialog`
);
closeMainDialog();
}
function clearDialogCrumbs() {
dialogCrumbs.value = [];
}
@@ -260,6 +330,8 @@ export const useUiStore = defineStore('Ui', () => {
jumpDialogCrumb,
clearDialogCrumbs,
closeMainDialog,
openDialog
openDialog,
jumpBackDialogCrumb,
handleBreadcrumbClick
};
});
+3 -1
View File
@@ -859,7 +859,9 @@ export const useUserStore = defineStore('User', () => {
})
.catch((err) => {
D.loading = false;
uiStore.closeMainDialog();
D.id = null;
D.visible = false;
uiStore.jumpBackDialogCrumb();
toast.error(t('message.user.load_failed'));
throw err;
})
+3 -1
View File
@@ -148,7 +148,9 @@ export const useWorldStore = defineStore('World', () => {
})
.catch((err) => {
D.loading = false;
uiStore.closeMainDialog();
D.id = null;
D.visible = false;
uiStore.jumpBackDialogCrumb();
toast.error(t('message.world.load_failed'));
throw err;
})