From 0f3791510e49bf67a49881faddefc55550f1d7fd Mon Sep 17 00:00:00 2001 From: Arild Matsson Date: Thu, 25 Jan 2024 09:58:18 +0100 Subject: [PATCH] Handle source not found --- src/corpus/sources/SourceView.vue | 12 ++++++++---- src/i18n/locales/en.yaml | 1 + src/i18n/locales/sv.yaml | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/corpus/sources/SourceView.vue b/src/corpus/sources/SourceView.vue index 8b5ef75..2757886 100644 --- a/src/corpus/sources/SourceView.vue +++ b/src/corpus/sources/SourceView.vue @@ -8,6 +8,7 @@ import useSources from "./sources.composable"; import SourceText from "./SourceText.vue"; import PendingContent from "@/spin/PendingContent.vue"; import useLocale from "@/i18n/locale.composable"; +import MessageAlert from "@/message/MessageAlert.vue"; const props = defineProps<{ corpusId: string; @@ -19,11 +20,9 @@ const { downloadSource, downloadPlaintext } = useSources(props.corpusId); const { isJobDone } = useJob(props.corpusId); const { filesize } = useLocale(); -// TODO Handle missing source (e.g. due to user visiting old url) +const sources = computed(() => corpusStore.corpora[props.corpusId].sources); const metadata = computed(() => - corpusStore.corpora[props.corpusId].sources?.find( - (source) => source.name === props.filename - ) + sources.value?.find((source) => source.name === props.filename) ); const isBinary = computed(() => metadata.value?.type.indexOf("text/") !== 0); const isPlaintext = computed(() => metadata.value?.type == "text/plain"); @@ -42,6 +41,11 @@ async function loadPlain() {