Initial Commit
This commit is contained in:
@@ -6,6 +6,9 @@ import type { StoryDetail } from '@/types/dredge.types';
|
||||
|
||||
const props = defineProps<{
|
||||
username: string;
|
||||
// When set, opens this specific (possibly expired) story item directly
|
||||
// instead of the user's current live tray.
|
||||
itemId?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -30,12 +33,15 @@ async function fetchStory() {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
const response = await fetch(`/api/stories/${props.username}`);
|
||||
const url = props.itemId ? `/api/story-items/${props.itemId}` : `/api/stories/${props.username}`;
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error('Failed to load story');
|
||||
detail.value = await response.json();
|
||||
currentIndex.value = detail.value?.start_index ?? 0;
|
||||
} catch (e) {
|
||||
error.value = 'Could not load this story.';
|
||||
error.value = props.itemId
|
||||
? 'This story is no longer available.'
|
||||
: 'Could not load this story.';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user