fix current directory not updating when modifying stuff

This commit is contained in:
2025-07-18 15:01:38 +02:00
parent 48cbd532c2
commit ec8e73507c
4 changed files with 29 additions and 18 deletions

View File

@@ -61,7 +61,7 @@ async function onClick() {
<ContextMenu> <ContextMenu>
<ContextMenuTrigger> <ContextMenuTrigger>
<button <button
:disabled="warrenStore.loading" :disabled="warrenStore.loading || disabled"
:class="[ :class="[
'bg-accent/30 border-border flex w-52 flex-row gap-4 overflow-hidden rounded-md border-1 px-4 py-2 select-none', 'bg-accent/30 border-border flex w-52 flex-row gap-4 overflow-hidden rounded-md border-1 px-4 py-2 select-none',
{ {

View File

@@ -0,0 +1,9 @@
export function useWarrenPath() {
const store = useWarrenStore();
if (store.current == null) {
return null;
}
return `${store.current.warrenId}/${store.current.path}`;
}

View File

@@ -1,6 +1,5 @@
import { toast } from 'vue-sonner'; import { toast } from 'vue-sonner';
import type { ApiResponse } from '~/types/api'; import type { ApiResponse } from '~/types/api';
import { getAuthSessionData } from './getSession';
import type { AuthUser } from '~/types/auth'; import type { AuthUser } from '~/types/auth';
export async function loginUser( export async function loginUser(

View File

@@ -1,9 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computedAsync } from '@vueuse/core';
import DirectoryListContextMenu from '~/components/DirectoryListContextMenu.vue'; import DirectoryListContextMenu from '~/components/DirectoryListContextMenu.vue';
import RenameEntryDialog from '~/components/actions/RenameEntryDialog.vue'; import RenameEntryDialog from '~/components/actions/RenameEntryDialog.vue';
import { getWarrenDirectory } from '~/lib/api/warrens'; import { getWarrenDirectory } from '~/lib/api/warrens';
import type { DirectoryEntry } from '~/types';
definePageMeta({ definePageMeta({
middleware: ['authenticated'], middleware: ['authenticated'],
@@ -11,6 +9,7 @@ definePageMeta({
const warrenStore = useWarrenStore(); const warrenStore = useWarrenStore();
const loadingIndicator = useLoadingIndicator(); const loadingIndicator = useLoadingIndicator();
const warrenPath = computed(() => useWarrenPath());
if (warrenStore.current == null) { if (warrenStore.current == null) {
await navigateTo({ await navigateTo({
@@ -18,24 +17,28 @@ if (warrenStore.current == null) {
}); });
} }
const entries = computedAsync<DirectoryEntry[]>(async () => { const entries = useAsyncData(
if (warrenStore.current == null) { 'current-directory',
return []; async () => {
} if (warrenStore.current == null) {
return [];
}
loadingIndicator.start(); loadingIndicator.start();
warrenStore.loading = true; warrenStore.loading = true;
const entries = await getWarrenDirectory( const entries = await getWarrenDirectory(
warrenStore.current.warrenId, warrenStore.current.warrenId,
warrenStore.current.path warrenStore.current.path
); );
warrenStore.loading = false; warrenStore.loading = false;
loadingIndicator.finish(); loadingIndicator.finish();
return entries; return entries;
}, []); },
{ watch: [warrenPath] }
).data;
</script> </script>
<template> <template>