diff --git a/front/src/components/channels/UploadForm.vue b/front/src/components/channels/UploadForm.vue index 9ffdf05cb..c4a33d334 100644 --- a/front/src/components/channels/UploadForm.vue +++ b/front/src/components/channels/UploadForm.vue @@ -33,7 +33,8 @@ interface Events { } interface Props { - channel: Channel | null + channel: Channel | null, + filter: 'podcast' | 'music' } interface QuotaStatus { @@ -136,7 +137,7 @@ const createEmptyChannel = async () => { const fetchChannels = async () => { isLoading.value = true try { - const response = await axios.get('channels/', { params: { scope: 'me' } }) + const response = await axios.get('channels/', { params: { scope: 'me' /* Ask Pablo: which param to filter for `music` | `podcast`? */ } }) availableChannels.value = response.data.results } catch (error) { errors.value = (error as BackendError).backendErrors diff --git a/front/src/store/channels.ts b/front/src/store/channels.ts index c1649d416..f4f72c9ad 100644 --- a/front/src/store/channels.ts +++ b/front/src/store/channels.ts @@ -28,7 +28,6 @@ const store: Module = { state: { subscriptions: [], count: 0, - // TODO: Remove this. It has been moved to store/ui showUploadModal: false, latestPublication: null, uploadModalConfig: { diff --git a/front/src/ui/modals/Upload.vue b/front/src/ui/modals/Upload.vue index 681059b88..e8d2c1834 100644 --- a/front/src/ui/modals/Upload.vue +++ b/front/src/ui/modals/Upload.vue @@ -20,18 +20,27 @@ import LibraryUpload from '~/components/library/FileUpload.vue' import LibraryWidget from '~/components/federation/LibraryWidget.vue' const { t } = useI18n() +const store = useStore() onKeyboardShortcut('u', () => useModal('upload').toggle()) const isOpen = useModal('upload').isOpen -type UploadDestination = 'channel' | 'library' | 'podcast' +type UploadDestination = + | { type: 'channel', channel?: Channel | null, filter?: 'podcast' | 'music' } + | { type: 'library' } type State = { uploadDestination? : UploadDestination, page: typeof pages[number], files?: string[] } // initial state -const init = () => ({ page : 'selectDestination' } as const) +const init = () => ( + store.state.channels.uploadModalConfig.channel ? + { page: 'uploadFiles', + uploadDestination: { type: 'channel', channel: store.state.channels.uploadModalConfig.channel } + } as const + : { page : 'selectDestination' } as const +) const state = ref(init()) const pages = ['selectDestination', 'uploadFiles', 'uploadsInProgress'] as const diff --git a/front/src/views/channels/DetailBase.vue b/front/src/views/channels/DetailBase.vue index 5525153cd..c545c8fb9 100644 --- a/front/src/views/channels/DetailBase.vue +++ b/front/src/views/channels/DetailBase.vue @@ -107,8 +107,8 @@ const fetchData = async () => { watch(() => props.id, fetchData, { immediate: true }) - const uuid = computed(() => store.state.channels.latestPublication?.channel.uuid) + watch([uuid, object], ([uuid, object], [lastUuid, lastObject]) => { if (object?.uuid && object.uuid === lastObject?.uuid) return @@ -119,7 +119,13 @@ watch([uuid, object], ([uuid, object], [lastUuid, lastObject]) => { const route = useRoute() watchEffect(() => { - if (!object.value) return + if (!object.value) { + store.state.channels.uploadModalConfig.channel = null + return + } else { + store.state.channels.uploadModalConfig.channel = object.value + } + if (!store.state.auth.authenticated && store.getters['instance/domain'] !== object.value.actor.domain) { router.push({ name: 'login', query: { next: route.fullPath } }) }