1
0
Fork 0
forked from mirror/pixelfed

Update ComposeModal, add processing step disabled by default

This commit is contained in:
Daniel Supernault 2021-02-05 21:19:12 -07:00
parent 33b625f508
commit e6e76e809d
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -59,11 +59,13 @@
</b-tooltip> </b-tooltip>
</span> </span>
<span v-else-if="page == 3"> <span v-else-if="page == 3">
<a class="text-lighter text-decoration-none mr-3 d-flex align-items-center" href="#" @click.prevent="goBack()"> <span v-if="media[0].mime != 'video/mp4'">
<i class="fas fa-long-arrow-alt-left fa-lg mr-2"></i> <a class="text-lighter text-decoration-none mr-3 d-flex align-items-center" href="#" @click.prevent="goBack()">
<span class="btn btn-outline-secondary btn-sm px-2 py-0 disabled" disabled="">{{media.length}}</span> <i class="fas fa-long-arrow-alt-left fa-lg mr-2"></i>
</a> <span class="btn btn-outline-secondary btn-sm px-2 py-0 disabled" disabled="">{{media.length}}</span>
<span class="font-weight-bold mb-0">{{pageTitle}}</span> </a>
<span class="font-weight-bold mb-0">{{pageTitle}}</span>
</span>
</span> </span>
<span v-else> <span v-else>
<a class="text-lighter text-decoration-none mr-3" href="#" @click.prevent="goBack()"><i class="fas fa-long-arrow-alt-left fa-lg"></i></a> <a class="text-lighter text-decoration-none mr-3" href="#" @click.prevent="goBack()"><i class="fas fa-long-arrow-alt-left fa-lg"></i></a>
@ -561,6 +563,34 @@
</p> </p>
</div> </div>
<div v-if="page == 'processingVideo'" class="w-100 h-100 px-3 d-flex justify-content-center align-items-center" style="height: 50vh !important;">
<div v-if="isProcessingMedia" class="text-center">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<p class="text-center font-weight-bold mb-1 mt-2">
Processing Media
</p>
<p class="text-center text-muted small mb-0">
This may take a few seconds.
</p>
</div>
</div>
<div v-if="page == 'processingPhoto'" class="w-100 h-100 px-3 d-flex justify-content-center align-items-center" style="height: 50vh !important;">
<div v-if="isProcessingMedia" class="text-center">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<p class="text-center font-weight-bold mb-1 mt-2">
Processing Media
</p>
<p class="text-center text-muted small mb-0">
This may take a few seconds.
</p>
</div>
</div>
</div> </div>
<!-- card-footers --> <!-- card-footers -->
@ -685,12 +715,17 @@ export default {
'editMedia', 'editMedia',
'cameraRoll', 'cameraRoll',
'tagPeopleHelp', 'tagPeopleHelp',
'textOptions' 'textOptions',
'processingVideo',
'processingPhoto'
], ],
cameraRollMedia: [], cameraRollMedia: [],
taggedUsernames: [], taggedUsernames: [],
taggedPeopleSearch: null, taggedPeopleSearch: null,
textMode: false textMode: false,
isProcessingMedia: false,
processPhotoInterval: undefined,
processVideoInterval: undefined
} }
}, },
@ -790,9 +825,14 @@ export default {
self.ids.push(e.data.id); self.ids.push(e.data.id);
self.media.push(e.data); self.media.push(e.data);
self.uploading = false; self.uploading = false;
setTimeout(function() {
self.page = 2; if(e.data.mime == 'video/mp4') {
}, 300); self.processVideo(e.data);
return;
} else {
self.processPhoto(e.data);
return;
}
}).catch(function(e) { }).catch(function(e) {
switch(e.response.status) { switch(e.response.status) {
case 451: case 451:
@ -1165,7 +1205,6 @@ export default {
ctx.clearRect(0, 0, image.width, image.height); ctx.clearRect(0, 0, image.width, image.height);
} }
} }
}, },
tagSearch(input) { tagSearch(input) {
@ -1208,7 +1247,58 @@ export default {
showTextOptions() { showTextOptions() {
this.page = 'textOptions'; this.page = 'textOptions';
this.pageTitle = 'Text Post Options'; this.pageTitle = 'Text Post Options';
},
processPhoto(media) {
this.page = 'processingPhoto';
this.pageTitle = '';
this.processPhotoCheck(media);
},
processPhotoCheck(media) {
this.isProcessingMedia = true;
this.processMediaCheck(media);
this.processPhotoInterval = setInterval(() => {
this.processMediaCheck(media);
}, 2500);
},
processVideo(media) {
this.page = 'processingVideo';
this.pageTitle = '';
this.processVideoCheck(media);
},
processVideoCheck(media) {
this.isProcessingMedia = true;
this.processMediaCheck(media, 'video');
this.processVideoInterval = setInterval(() => {
this.processMediaCheck(media, 'video');
}, 2500);
},
processMediaCheck(media, type = 'photo') {
return axios.get('/api/compose/v0/media/processing', {
params: {
id: media.id
}
}).then(res => {
let data = res.data;
if(data.finished === true) {
this.isProcessingMedia = false;
this.page = 3;
if(type == 'photo') {
clearInterval(this.processPhotoInterval);
} else if (type == 'video') {
clearInterval(this.processVideoInterval);
} else {
}
return;
}
});
} }
} }
} }
</script> </script>