mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
Open last dialog on error
This commit is contained in:
@@ -131,44 +131,9 @@
|
|||||||
return dialogCrumbs.value.slice(1, -2);
|
return dialogCrumbs.value.slice(1, -2);
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleBreadcrumbClick = (index) => {
|
function handleBreadcrumbClick(index) {
|
||||||
const item = dialogCrumbs.value[index];
|
uiStore.handleBreadcrumbClick(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 });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
useAvatarStore,
|
useAvatarStore,
|
||||||
useModalStore,
|
useModalStore,
|
||||||
useNotificationStore,
|
useNotificationStore,
|
||||||
|
useUiStore,
|
||||||
useUpdateLoopStore,
|
useUpdateLoopStore,
|
||||||
useUserStore
|
useUserStore
|
||||||
} from '../stores';
|
} from '../stores';
|
||||||
@@ -36,6 +37,7 @@ export function request(endpoint, options) {
|
|||||||
const modalStore = useModalStore();
|
const modalStore = useModalStore();
|
||||||
const notificationStore = useNotificationStore();
|
const notificationStore = useNotificationStore();
|
||||||
const updateLoopStore = useUpdateLoopStore();
|
const updateLoopStore = useUpdateLoopStore();
|
||||||
|
const uiStore = useUiStore();
|
||||||
if (
|
if (
|
||||||
!watchState.isLoggedIn &&
|
!watchState.isLoggedIn &&
|
||||||
endpoint.startsWith('/auth') &&
|
endpoint.startsWith('/auth') &&
|
||||||
@@ -202,6 +204,9 @@ export function request(endpoint, options) {
|
|||||||
) {
|
) {
|
||||||
toast.error(t('message.api_handler.avatar_private_or_deleted'));
|
toast.error(t('message.api_handler.avatar_private_or_deleted'));
|
||||||
avatarStore.avatarDialog.visible = false;
|
avatarStore.avatarDialog.visible = false;
|
||||||
|
avatarStore.avatarDialog.loading = false;
|
||||||
|
avatarStore.avatarDialog.id = null;
|
||||||
|
uiStore.jumpBackDialogCrumb();
|
||||||
$throw(404, data.error?.message || '', endpoint);
|
$throw(404, data.error?.message || '', endpoint);
|
||||||
}
|
}
|
||||||
if (status === 404 && endpoint.endsWith('/persist/exists')) {
|
if (status === 404 && endpoint.endsWith('/persist/exists')) {
|
||||||
|
|||||||
@@ -221,8 +221,11 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
|||||||
ref2.authorId !== userStore.currentUser.id
|
ref2.authorId !== userStore.currentUser.id
|
||||||
) {
|
) {
|
||||||
D.loading = false;
|
D.loading = false;
|
||||||
uiStore.closeMainDialog();
|
D.id = null;
|
||||||
return;
|
D.visible = false;
|
||||||
|
uiStore.jumpBackDialogCrumb();
|
||||||
|
toast.error(t('message.api_handler.avatar_private_or_deleted'));
|
||||||
|
throw new Error('Avatar is private or deleted');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
avatarRequest
|
avatarRequest
|
||||||
@@ -263,6 +266,10 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
D.visible = false;
|
D.visible = false;
|
||||||
|
D.id = null;
|
||||||
|
D.visible = false;
|
||||||
|
uiStore.jumpBackDialogCrumb();
|
||||||
|
toast.error(t('message.api_handler.avatar_private_or_deleted'));
|
||||||
throw err;
|
throw err;
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
|||||||
+3
-1
@@ -168,7 +168,9 @@ export const useGroupStore = defineStore('Group', () => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
D.loading = false;
|
D.loading = false;
|
||||||
uiStore.closeMainDialog();
|
D.id = null;
|
||||||
|
D.visible = false;
|
||||||
|
uiStore.jumpBackDialogCrumb();
|
||||||
toast.error(t('message.group.load_failed'));
|
toast.error(t('message.group.load_failed'));
|
||||||
throw err;
|
throw err;
|
||||||
})
|
})
|
||||||
|
|||||||
+73
-1
@@ -18,6 +18,11 @@ import { useWorldStore } from './world';
|
|||||||
|
|
||||||
export const useUiStore = defineStore('Ui', () => {
|
export const useUiStore = defineStore('Ui', () => {
|
||||||
const notificationStore = useNotificationStore();
|
const notificationStore = useNotificationStore();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const worldStore = useWorldStore();
|
||||||
|
const avatarStore = useAvatarStore();
|
||||||
|
const groupStore = useGroupStore();
|
||||||
|
const instanceStore = useInstanceStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const keys = useMagicKeys();
|
const keys = useMagicKeys();
|
||||||
const { directAccessPaste } = useSearchStore();
|
const { directAccessPaste } = useSearchStore();
|
||||||
@@ -108,6 +113,71 @@ export const useUiStore = defineStore('Ui', () => {
|
|||||||
dialogCrumbs.value.splice(index + 1);
|
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() {
|
function clearDialogCrumbs() {
|
||||||
dialogCrumbs.value = [];
|
dialogCrumbs.value = [];
|
||||||
}
|
}
|
||||||
@@ -260,6 +330,8 @@ export const useUiStore = defineStore('Ui', () => {
|
|||||||
jumpDialogCrumb,
|
jumpDialogCrumb,
|
||||||
clearDialogCrumbs,
|
clearDialogCrumbs,
|
||||||
closeMainDialog,
|
closeMainDialog,
|
||||||
openDialog
|
openDialog,
|
||||||
|
jumpBackDialogCrumb,
|
||||||
|
handleBreadcrumbClick
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
+3
-1
@@ -859,7 +859,9 @@ export const useUserStore = defineStore('User', () => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
D.loading = false;
|
D.loading = false;
|
||||||
uiStore.closeMainDialog();
|
D.id = null;
|
||||||
|
D.visible = false;
|
||||||
|
uiStore.jumpBackDialogCrumb();
|
||||||
toast.error(t('message.user.load_failed'));
|
toast.error(t('message.user.load_failed'));
|
||||||
throw err;
|
throw err;
|
||||||
})
|
})
|
||||||
|
|||||||
+3
-1
@@ -148,7 +148,9 @@ export const useWorldStore = defineStore('World', () => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
D.loading = false;
|
D.loading = false;
|
||||||
uiStore.closeMainDialog();
|
D.id = null;
|
||||||
|
D.visible = false;
|
||||||
|
uiStore.jumpBackDialogCrumb();
|
||||||
toast.error(t('message.world.load_failed'));
|
toast.error(t('message.world.load_failed'));
|
||||||
throw err;
|
throw err;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user