Fix jumpDialogCrumb

This commit is contained in:
Natsumi
2026-02-03 13:54:59 +13:00
parent 5a27e6fb51
commit 50a037686b
7 changed files with 25 additions and 63 deletions
-5
View File
@@ -202,11 +202,6 @@ export function request(endpoint, options) {
status === 404 && status === 404 &&
endpoint?.startsWith('avatars/') endpoint?.startsWith('avatars/')
) { ) {
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); $throw(404, data.error?.message || '', endpoint);
} }
if (status === 404 && endpoint.endsWith('/persist/exists')) { if (status === 404 && endpoint.endsWith('/persist/exists')) {
+3 -15
View File
@@ -178,12 +178,11 @@ export const useAvatarStore = defineStore('Avatar', () => {
* @param {string} avatarId * @param {string} avatarId
* @returns * @returns
*/ */
function showAvatarDialog(avatarId, options = {}) { function showAvatarDialog(avatarId) {
const D = avatarDialog.value; const D = avatarDialog.value;
uiStore.openDialog({ uiStore.openDialog({
type: 'avatar', type: 'avatar',
id: avatarId, id: avatarId
skipBreadcrumb: options.skipBreadcrumb
}); });
D.visible = true; D.visible = true;
if (D.id === avatarId) { if (D.id === avatarId) {
@@ -217,17 +216,6 @@ export const useAvatarStore = defineStore('Avatar', () => {
if (typeof ref2 !== 'undefined') { if (typeof ref2 !== 'undefined') {
D.ref = ref2; D.ref = ref2;
uiStore.setDialogCrumbLabel('avatar', D.id, D.ref?.name || D.id); uiStore.setDialogCrumbLabel('avatar', D.id, D.ref?.name || D.id);
if (
ref2.releaseStatus !== 'public' &&
ref2.authorId !== userStore.currentUser.id
) {
D.loading = false;
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 avatarRequest
.getAvatar({ avatarId }) .getAvatar({ avatarId })
@@ -266,7 +254,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
} }
}) })
.catch((err) => { .catch((err) => {
D.visible = false; D.loading = false;
D.id = null; D.id = null;
D.visible = false; D.visible = false;
uiStore.jumpBackDialogCrumb(); uiStore.jumpBackDialogCrumb();
+2 -3
View File
@@ -131,14 +131,13 @@ export const useGroupStore = defineStore('Group', () => {
{ flush: 'sync' } { flush: 'sync' }
); );
function showGroupDialog(groupId, options = {}) { function showGroupDialog(groupId) {
if (!groupId) { if (!groupId) {
return; return;
} }
uiStore.openDialog({ uiStore.openDialog({
type: 'group', type: 'group',
id: groupId, id: groupId
skipBreadcrumb: options.skipBreadcrumb
}); });
const D = groupDialog.value; const D = groupDialog.value;
D.visible = true; D.visible = true;
+4 -10
View File
@@ -285,7 +285,7 @@ export const useInstanceStore = defineStore('Instance', () => {
return `${baseLabel} · ${accessTypeLabel}`; return `${baseLabel} · ${accessTypeLabel}`;
} }
function showPreviousInstancesInfoDialog(instanceId, options = {}) { function showPreviousInstancesInfoDialog(instanceId) {
previousInstancesInfoDialog.value.visible = true; previousInstancesInfoDialog.value.visible = true;
previousInstancesInfoDialog.value.instanceId = instanceId; previousInstancesInfoDialog.value.instanceId = instanceId;
uiStore.openDialog({ uiStore.openDialog({
@@ -293,8 +293,7 @@ export const useInstanceStore = defineStore('Instance', () => {
id: instanceId || '', id: instanceId || '',
label: instanceId label: instanceId
? formatPreviousInstancesInfoLabel(instanceId) ? formatPreviousInstancesInfoLabel(instanceId)
: '', : ''
skipBreadcrumb: options.skipBreadcrumb
}); });
if (instanceId) { if (instanceId) {
const location = parseLocation(instanceId); const location = parseLocation(instanceId);
@@ -319,11 +318,7 @@ export const useInstanceStore = defineStore('Instance', () => {
} }
} }
async function showPreviousInstancesListDialog( async function showPreviousInstancesListDialog(variant, targetRef) {
variant,
targetRef,
options = {}
) {
previousInstancesListDialog.value.variant = variant; previousInstancesListDialog.value.variant = variant;
let resolved = null; let resolved = null;
if (variant === 'user') { if (variant === 'user') {
@@ -346,8 +341,7 @@ export const useInstanceStore = defineStore('Instance', () => {
uiStore.openDialog({ uiStore.openDialog({
type: `previous-instances-${variant}`, type: `previous-instances-${variant}`,
id: dialogId, id: dialogId,
label, label
skipBreadcrumb: options.skipBreadcrumb
}); });
} }
+12 -24
View File
@@ -114,8 +114,8 @@ export const useUiStore = defineStore('Ui', () => {
} }
function jumpBackDialogCrumb() { function jumpBackDialogCrumb() {
if (dialogCrumbs.value.length > 1) { if (dialogCrumbs.value.length > 0) {
dialogCrumbs.value.splice(dialogCrumbs.value.length - 1); dialogCrumbs.value.pop();
} }
if (dialogCrumbs.value.length === 0) { if (dialogCrumbs.value.length === 0) {
closeMainDialog(); closeMainDialog();
@@ -131,45 +131,35 @@ export const useUiStore = defineStore('Ui', () => {
} }
jumpDialogCrumb(index); jumpDialogCrumb(index);
if (item.type === 'user') { if (item.type === 'user') {
userStore.showUserDialog(item.id, { skipBreadcrumb: true }); userStore.showUserDialog(item.id);
return; return;
} }
if (item.type === 'world') { if (item.type === 'world') {
worldStore.showWorldDialog(item.id, null, { worldStore.showWorldDialog(item.id, null);
skipBreadcrumb: true
});
return; return;
} }
if (item.type === 'avatar') { if (item.type === 'avatar') {
avatarStore.showAvatarDialog(item.id, { skipBreadcrumb: true }); avatarStore.showAvatarDialog(item.id);
return; return;
} }
if (item.type === 'group') { if (item.type === 'group') {
groupStore.showGroupDialog(item.id, { skipBreadcrumb: true }); groupStore.showGroupDialog(item.id);
return; return;
} }
if (item.type === 'previous-instances-user') { if (item.type === 'previous-instances-user') {
instanceStore.showPreviousInstancesListDialog('user', item.id, { instanceStore.showPreviousInstancesListDialog('user', item.id);
skipBreadcrumb: true
});
return; return;
} }
if (item.type === 'previous-instances-world') { if (item.type === 'previous-instances-world') {
instanceStore.showPreviousInstancesListDialog('world', item.id, { instanceStore.showPreviousInstancesListDialog('world', item.id);
skipBreadcrumb: true
});
return; return;
} }
if (item.type === 'previous-instances-group') { if (item.type === 'previous-instances-group') {
instanceStore.showPreviousInstancesListDialog('group', item.id, { instanceStore.showPreviousInstancesListDialog('group', item.id);
skipBreadcrumb: true
});
return; return;
} }
if (item.type === 'previous-instances-info') { if (item.type === 'previous-instances-info') {
instanceStore.showPreviousInstancesInfoDialog(item.id, { instanceStore.showPreviousInstancesInfoDialog(item.id);
skipBreadcrumb: true
});
return; return;
} }
console.error( console.error(
@@ -197,7 +187,7 @@ export const useUiStore = defineStore('Ui', () => {
clearDialogCrumbs(); clearDialogCrumbs();
} }
function openDialog({ type, id, label = '', skipBreadcrumb = false }) { function openDialog({ type, id, label = '' }) {
const userStore = useUserStore(); const userStore = useUserStore();
const worldStore = useWorldStore(); const worldStore = useWorldStore();
const avatarStore = useAvatarStore(); const avatarStore = useAvatarStore();
@@ -239,9 +229,7 @@ export const useUiStore = defineStore('Ui', () => {
if (!hadActiveDialog) { if (!hadActiveDialog) {
clearDialogCrumbs(); clearDialogCrumbs();
} }
if (!skipBreadcrumb) { pushDialogCrumb(type, id, label);
pushDialogCrumb(type, id, label);
}
} }
// Make sure file drops outside of the screenshot manager don't navigate to the file path dropped. // Make sure file drops outside of the screenshot manager don't navigate to the file path dropped.
+2 -3
View File
@@ -763,7 +763,7 @@ export const useUserStore = defineStore('User', () => {
* *
* @param {string} userId * @param {string} userId
*/ */
function showUserDialog(userId, options = {}) { function showUserDialog(userId) {
if ( if (
!userId || !userId ||
typeof userId !== 'string' || typeof userId !== 'string' ||
@@ -773,8 +773,7 @@ export const useUserStore = defineStore('User', () => {
} }
uiStore.openDialog({ uiStore.openDialog({
type: 'user', type: 'user',
id: userId, id: userId
skipBreadcrumb: options.skipBreadcrumb
}); });
const D = userDialog.value; const D = userDialog.value;
D.visible = true; D.visible = true;
+2 -3
View File
@@ -78,7 +78,7 @@ export const useWorldStore = defineStore('World', () => {
* @param {string} tag * @param {string} tag
* @param {string} shortName * @param {string} shortName
*/ */
function showWorldDialog(tag, shortName = null, options = {}) { function showWorldDialog(tag, shortName = null) {
const D = worldDialog; const D = worldDialog;
const L = parseLocation(tag); const L = parseLocation(tag);
if (L.worldId === '') { if (L.worldId === '') {
@@ -86,8 +86,7 @@ export const useWorldStore = defineStore('World', () => {
} }
uiStore.openDialog({ uiStore.openDialog({
type: 'world', type: 'world',
id: L.worldId, id: L.worldId
skipBreadcrumb: options.skipBreadcrumb
}); });
D.visible = true; D.visible = true;
if (D.id === L.worldId) { if (D.id === L.worldId) {