feat(upload): [WIP] #2081 respect user selected upload destination or jump to page 2 if a channel is already open

This commit is contained in:
upsiflu 2025-02-17 13:04:56 +01:00
parent 851d40c4aa
commit 148e87c28e
4 changed files with 22 additions and 7 deletions

View File

@ -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

View File

@ -28,7 +28,6 @@ const store: Module<State, RootState> = {
state: {
subscriptions: [],
count: 0,
// TODO: Remove this. It has been moved to store/ui
showUploadModal: false,
latestPublication: null,
uploadModalConfig: {

View File

@ -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<State>(init())
const pages = ['selectDestination', 'uploadFiles', 'uploadsInProgress'] as const

View File

@ -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 } })
}