Refactor input validation and add torrent state
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Jack Hadrill 2021-01-04 02:17:43 +00:00
parent f71519ecae
commit 285d35bc2a
3 changed files with 35 additions and 27 deletions

View File

@ -9,21 +9,9 @@
export default { export default {
setup () { setup () {
const items = [ const items = [
{ { label: 'Home', icon: 'pi pi-home', to: '/' },
label: 'Home', { label: 'Host', icon: 'pi pi-upload', to: '/host' },
icon: 'pi pi-home', { label: 'Join', icon: 'pi pi-video', to: '/join' }
to: '/'
},
{
label: 'Host',
icon: 'pi pi-upload',
to: '/host'
},
{
label: 'Join',
icon: 'pi pi-video',
to: '/join'
}
] ]
return { return {

View File

@ -34,5 +34,17 @@ app.component('Toast', Toast)
// Register VCinemaApp components. // Register VCinemaApp components.
app.component('FileSelect', FileSelect) app.component('FileSelect', FileSelect)
app.provide('trackers', [
'wss://tracker.sloppyta.co:443/announce',
'wss://tracker.files.fm:7073/announce',
'wss://open.tube:443/tracker/socket',
'wss://hub.bugout.link:443/announce',
'ws://tracker.sloppyta.co:80/announce',
'ws://tracker.lab.vvc.niif.hu:80/announce',
'ws://tracker.files.fm:7072/announce',
'ws://tracker.btsync.cf:6969/announce',
'ws://hub.bugout.link:80/announce'
])
// Render to DOM. // Render to DOM.
app.mount('#app') app.mount('#app')

View File

@ -7,31 +7,39 @@
<script> <script>
import { useToast } from 'primevue/usetoast' import { useToast } from 'primevue/usetoast'
import { ref } from 'vue' import { inject, ref, reactive } from 'vue'
const validateFileInput = (files) => {
if (files?.length !== 1 || !files[0].name.endsWith('.mp4') || files[0].type !== 'video/mp4') {
return false
}
return true
}
export default { export default {
setup () { setup () {
const toast = useToast() const toast = useToast()
const trackers = inject('trackers')
const file = ref() const file = ref()
const torrentState = reactive({
active: false
})
const filesSelected = (files) => { const filesSelected = (files) => {
if (files?.length !== 1) { if (!validateFileInput(files)) {
toast.add({ severity: 'error', summary: 'Bad file input', detail: 'You must select only one file.', life: 3000 }) toast.add({ severity: 'error', summary: 'Bad file input', detail: 'You must select a single H.264 encoded MP4.', life: 3000 })
return } else {
file.value = files[0]
} }
if (!files[0].name.endsWith('.mp4') || files[0].type !== 'video/mp4') { console.log(trackers)
toast.add({ severity: 'error', summary: 'Bad file input', detail: 'Only H.264 encoded MP4s are supported.', life: 3000 })
return
}
file.value = files[0]
} }
return { return {
filesSelected, filesSelected,
file file,
torrentState
} }
} }
} }