From e6e76e809d5b8469a4e2ad07de9df82be9310c86 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 5 Feb 2021 21:19:12 -0700 Subject: [PATCH] Update ComposeModal, add processing step disabled by default --- .../assets/js/components/ComposeModal.vue | 112 ++++++++++++++++-- 1 file changed, 101 insertions(+), 11 deletions(-) diff --git a/resources/assets/js/components/ComposeModal.vue b/resources/assets/js/components/ComposeModal.vue index 82499a14f..fc058a5f5 100644 --- a/resources/assets/js/components/ComposeModal.vue +++ b/resources/assets/js/components/ComposeModal.vue @@ -59,11 +59,13 @@ - - - {{media.length}} - - {{pageTitle}} + + + + {{media.length}} + + {{pageTitle}} + @@ -561,6 +563,34 @@

+
+
+
+ Loading... +
+

+ Processing Media +

+

+ This may take a few seconds. +

+
+
+ +
+
+
+ Loading... +
+

+ Processing Media +

+

+ This may take a few seconds. +

+
+
+ @@ -685,12 +715,17 @@ export default { 'editMedia', 'cameraRoll', 'tagPeopleHelp', - 'textOptions' + 'textOptions', + 'processingVideo', + 'processingPhoto' ], cameraRollMedia: [], taggedUsernames: [], 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.media.push(e.data); self.uploading = false; - setTimeout(function() { - self.page = 2; - }, 300); + + if(e.data.mime == 'video/mp4') { + self.processVideo(e.data); + return; + } else { + self.processPhoto(e.data); + return; + } }).catch(function(e) { switch(e.response.status) { case 451: @@ -1165,7 +1205,6 @@ export default { ctx.clearRect(0, 0, image.width, image.height); } } - }, tagSearch(input) { @@ -1208,7 +1247,58 @@ export default { showTextOptions() { this.page = 'textOptions'; 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; + } + }); } + + } }