aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShpuld Shpuldson <shp@cock.li>2020-06-28 15:14:01 +0300
committerShpuld Shpuldson <shp@cock.li>2020-06-28 15:14:01 +0300
commit3c47036101c4767b4e2fb316d9ea35535197af79 (patch)
treec9993418ab1b16509c4503a5653fe4fbc6247b47
parent0287d5c07e28f54be09825dcc5280dbef1c740c2 (diff)
add automatic updating
-rw-r--r--src/components/post_status_form/post_status_form.js14
-rw-r--r--src/components/post_status_form/post_status_form.vue7
2 files changed, 13 insertions, 8 deletions
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index 3f7e36a6..75b02ffb 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -6,7 +6,7 @@ import PollForm from '../poll/poll_form.vue'
import StatusContent from '../status_content/status_content.vue'
import fileTypeService from '../../services/file_type/file_type.service.js'
import { findOffset } from '../../services/offset_finder/offset_finder.service.js'
-import { reject, map, uniqBy } from 'lodash'
+import { reject, map, uniqBy, debounce } from 'lodash'
import suggestor from '../emoji_input/suggestor.js'
import { mapGetters } from 'vuex'
import Checkbox from '../checkbox/checkbox.vue'
@@ -228,6 +228,7 @@ const PostStatusForm = {
el.style.height = 'auto'
el.style.height = undefined
this.error = null
+ this.closePreview()
} else {
this.error = data.error
}
@@ -262,16 +263,25 @@ const PostStatusForm = {
this.previewLoading = false
})
},
+ debouncePreviewStatus: debounce(function (newStatus) {
+ this.previewStatus(newStatus)
+ }, 750),
+ autoPreview () {
+ this.previewLoading = true
+ this.debouncePreviewStatus(this.newStatus)
+ },
closePreview () {
this.preview = null
this.previewLoading = false
},
addMediaFile (fileInfo) {
this.newStatus.files.push(fileInfo)
+ this.autoPreview()
},
removeMediaFile (fileInfo) {
let index = this.newStatus.files.indexOf(fileInfo)
this.newStatus.files.splice(index, 1)
+ this.autoPreview()
},
uploadFailed (errString, templateArgs) {
templateArgs = templateArgs || {}
@@ -287,6 +297,7 @@ const PostStatusForm = {
return fileTypeService.fileType(fileInfo.mimetype)
},
paste (e) {
+ this.autoPreview()
this.resize(e)
if (e.clipboardData.files.length > 0) {
// prevent pasting of file as text
@@ -321,6 +332,7 @@ const PostStatusForm = {
}
},
onEmojiInputInput (e) {
+ this.autoPreview()
this.$nextTick(() => {
this.resize(this.$refs['textarea'])
})
diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue
index 0bee8bb5..31a4b388 100644
--- a/src/components/post_status_form/post_status_form.vue
+++ b/src/components/post_status_form/post_status_form.vue
@@ -36,13 +36,6 @@
class="icon-spin3 animate-spin"
/>
<a
- v-else
- class="preview-update"
- @click.stop.prevent="previewStatus(newStatus)"
- >
- {{ $t('status.preview_update') }}
- </a>
- <a
class="preview-close"
@click.stop.prevent="closePreview"
>