mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
Open last dialog on error
This commit is contained in:
@@ -131,44 +131,9 @@
|
||||
return dialogCrumbs.value.slice(1, -2);
|
||||
});
|
||||
|
||||
const handleBreadcrumbClick = (index) => {
|
||||
const item = dialogCrumbs.value[index];
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
uiStore.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 });
|
||||
}
|
||||
};
|
||||
function handleBreadcrumbClick(index) {
|
||||
uiStore.handleBreadcrumbClick(index);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
useAvatarStore,
|
||||
useModalStore,
|
||||
useNotificationStore,
|
||||
useUiStore,
|
||||
useUpdateLoopStore,
|
||||
useUserStore
|
||||
} from '../stores';
|
||||
@@ -36,6 +37,7 @@ export function request(endpoint, options) {
|
||||
const modalStore = useModalStore();
|
||||
const notificationStore = useNotificationStore();
|
||||
const updateLoopStore = useUpdateLoopStore();
|
||||
const uiStore = useUiStore();
|
||||
if (
|
||||
!watchState.isLoggedIn &&
|
||||
endpoint.startsWith('/auth') &&
|
||||
@@ -202,6 +204,9 @@ export function request(endpoint, options) {
|
||||
) {
|
||||
toast.error(t('message.api_handler.avatar_private_or_deleted'));
|
||||
avatarStore.avatarDialog.visible = false;
|
||||
avatarStore.avatarDialog.loading = false;
|
||||
avatarStore.avatarDialog.id = null;
|
||||
uiStore.jumpBackDialogCrumb();
|
||||
$throw(404, data.error?.message || '', endpoint);
|
||||
}
|
||||
if (status === 404 && endpoint.endsWith('/persist/exists')) {
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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;
|
||||
})
|
||||
|
||||
@@ -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
|
||||
};
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
})
|
||||
|
||||
@@ -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;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user