Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MS] Update workspace history page when route changes #9691

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions client/src/views/workspaces/WorkspaceHistoryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@

<script setup lang="ts">
import { IonPage, IonList, IonLabel, IonButtons, IonIcon, IonButton, IonListHeader, IonContent, IonText } from '@ionic/vue';
import { computed, onBeforeUnmount, onMounted, ref, Ref, inject } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref, Ref, inject, onUnmounted } from 'vue';
import { FsPath, Path, getWorkspaceInfo, StartedWorkspaceInfo, statFolderChildrenAt, entryStatAt, EntryName } from '@/parsec';
import { MsCheckbox, MsSpinner, MsSearchInput, askQuestion, Answer, MsDatetimePicker, I18n } from 'megashark-lib';
import { DateTime } from 'luxon';
import { RouterPathNode } from '@/components/header/HeaderBreadcrumbs.vue';
import HeaderBreadcrumbs from '@/components/header/HeaderBreadcrumbs.vue';
import { WorkspaceHistoryEntryCollection, WorkspaceHistoryEntryModel, HistoryFileListItem } from '@/components/files';
import { chevronBack, chevronForward, warning } from 'ionicons/icons';
import { currentRouteIs, getCurrentRouteQuery, getDocumentPath, getWorkspaceHandle, Routes } from '@/router';
import { currentRouteIs, getCurrentRouteQuery, getDocumentPath, getWorkspaceHandle, Routes, watchRoute } from '@/router';
import { FileOperationManager, FileOperationManagerKey } from '@/services/fileOperationManager';
import { SortProperty } from '@/components/users';
import { InformationManager, InformationManagerKey } from '@/services/informationManager';
Expand Down Expand Up @@ -183,7 +183,14 @@ const someSelected = computed(() => {
return entries.value.selectedCount() > 0;
});

onMounted(async () => {
const cancelRouteWatch = watchRoute(async () => {
if (!currentRouteIs(Routes.History)) {
return;
}
await loadHistory();
});

async function loadHistory(): Promise<void> {
const workspaceHandle = getWorkspaceHandle();
if (workspaceHandle) {
const infoResult = await getWorkspaceInfo(workspaceHandle);
Expand All @@ -202,6 +209,10 @@ onMounted(async () => {
}

await listCurrentPath();
}

onMounted(async () => {
await loadHistory();
});

onBeforeUnmount(async () => {
Expand All @@ -211,6 +222,10 @@ onBeforeUnmount(async () => {
}
});

onUnmounted(async () => {
cancelRouteWatch();
});

async function onDateTimeChange(): Promise<void> {
await listCurrentPath();
}
Expand Down
Loading