Skip to content

Commit

Permalink
Use file sources store in composable to reduce requests
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 15, 2024
1 parent 4c5f059 commit aabd492
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion client/src/components/Common/ExportRecordDOILink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useFileSources } from "@/composables/fileSources";
import DOILink from "./DOILink.vue";
// TODO: This should be using a store so we don't have to load file sources in every component
const { getFileSourceByUri, isLoading: isLoadingFileSources } = useFileSources({ include: ["rdm"] });
interface Props {
Expand Down
7 changes: 5 additions & 2 deletions client/src/composables/fileSources.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { onMounted, readonly, ref } from "vue";

import { BrowsableFilesSourcePlugin, FilterFileSourcesOptions, getFileSources } from "@/api/remoteFiles";
import { BrowsableFilesSourcePlugin, FilterFileSourcesOptions } from "@/api/remoteFiles";
import { useFileSourcesStore } from "@/stores/fileSourcesStore";

/**
* Composable for accessing and working with file sources.
*
* @param options - The options to filter the file sources.
*/
export function useFileSources(options: FilterFileSourcesOptions = {}) {
const fileSourcesStore = useFileSourcesStore();

const isLoading = ref(true);
const hasWritable = ref(false);
const fileSources = ref<BrowsableFilesSourcePlugin[]>([]);

onMounted(async () => {
fileSources.value = await getFileSources(options);
fileSources.value = await fileSourcesStore.getFileSources(options);
hasWritable.value = fileSources.value.some((fs) => fs.writable);
isLoading.value = false;
});
Expand Down

0 comments on commit aabd492

Please sign in to comment.