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:
parent
851d40c4aa
commit
148e87c28e
|
@ -33,7 +33,8 @@ interface Events {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
channel: Channel | null
|
channel: Channel | null,
|
||||||
|
filter: 'podcast' | 'music'
|
||||||
}
|
}
|
||||||
|
|
||||||
interface QuotaStatus {
|
interface QuotaStatus {
|
||||||
|
@ -136,7 +137,7 @@ const createEmptyChannel = async () => {
|
||||||
const fetchChannels = async () => {
|
const fetchChannels = async () => {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
try {
|
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
|
availableChannels.value = response.data.results
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errors.value = (error as BackendError).backendErrors
|
errors.value = (error as BackendError).backendErrors
|
||||||
|
|
|
@ -28,7 +28,6 @@ const store: Module<State, RootState> = {
|
||||||
state: {
|
state: {
|
||||||
subscriptions: [],
|
subscriptions: [],
|
||||||
count: 0,
|
count: 0,
|
||||||
// TODO: Remove this. It has been moved to store/ui
|
|
||||||
showUploadModal: false,
|
showUploadModal: false,
|
||||||
latestPublication: null,
|
latestPublication: null,
|
||||||
uploadModalConfig: {
|
uploadModalConfig: {
|
||||||
|
|
|
@ -20,18 +20,27 @@ import LibraryUpload from '~/components/library/FileUpload.vue'
|
||||||
import LibraryWidget from '~/components/federation/LibraryWidget.vue'
|
import LibraryWidget from '~/components/federation/LibraryWidget.vue'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const store = useStore()
|
||||||
|
|
||||||
onKeyboardShortcut('u', () => useModal('upload').toggle())
|
onKeyboardShortcut('u', () => useModal('upload').toggle())
|
||||||
|
|
||||||
const isOpen = useModal('upload').isOpen
|
const isOpen = useModal('upload').isOpen
|
||||||
|
|
||||||
type UploadDestination = 'channel' | 'library' | 'podcast'
|
type UploadDestination =
|
||||||
|
| { type: 'channel', channel?: Channel | null, filter?: 'podcast' | 'music' }
|
||||||
|
| { type: 'library' }
|
||||||
|
|
||||||
type State =
|
type State =
|
||||||
{ uploadDestination? : UploadDestination, page: typeof pages[number], files?: string[] }
|
{ uploadDestination? : UploadDestination, page: typeof pages[number], files?: string[] }
|
||||||
|
|
||||||
// initial state
|
// 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 state = ref<State>(init())
|
||||||
|
|
||||||
const pages = ['selectDestination', 'uploadFiles', 'uploadsInProgress'] as const
|
const pages = ['selectDestination', 'uploadFiles', 'uploadsInProgress'] as const
|
||||||
|
|
|
@ -107,8 +107,8 @@ const fetchData = async () => {
|
||||||
|
|
||||||
watch(() => props.id, fetchData, { immediate: true })
|
watch(() => props.id, fetchData, { immediate: true })
|
||||||
|
|
||||||
|
|
||||||
const uuid = computed(() => store.state.channels.latestPublication?.channel.uuid)
|
const uuid = computed(() => store.state.channels.latestPublication?.channel.uuid)
|
||||||
|
|
||||||
watch([uuid, object], ([uuid, object], [lastUuid, lastObject]) => {
|
watch([uuid, object], ([uuid, object], [lastUuid, lastObject]) => {
|
||||||
if (object?.uuid && object.uuid === lastObject?.uuid) return
|
if (object?.uuid && object.uuid === lastObject?.uuid) return
|
||||||
|
|
||||||
|
@ -119,7 +119,13 @@ watch([uuid, object], ([uuid, object], [lastUuid, lastObject]) => {
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
watchEffect(() => {
|
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) {
|
if (!store.state.auth.authenticated && store.getters['instance/domain'] !== object.value.actor.domain) {
|
||||||
router.push({ name: 'login', query: { next: route.fullPath } })
|
router.push({ name: 'login', query: { next: route.fullPath } })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue