fixed a lot of bugs with emoji picker, improved relevant components

This commit is contained in:
Henry Jameson 2019-08-12 20:01:38 +03:00
parent 579b5c9e77
commit 5851f97eb0
12 changed files with 300 additions and 150 deletions

View file

@ -3,7 +3,6 @@ import MediaUpload from '../media_upload/media_upload.vue'
import ScopeSelector from '../scope_selector/scope_selector.vue'
import EmojiInput from '../emoji_input/emoji_input.vue'
import PollForm from '../poll/poll_form.vue'
import StickerPicker from '../sticker_picker/sticker_picker.vue'
import fileTypeService from '../../services/file_type/file_type.service.js'
import { reject, map, uniqBy } from 'lodash'
import suggestor from '../emoji_input/suggestor.js'
@ -35,7 +34,6 @@ const PostStatusForm = {
MediaUpload,
EmojiInput,
PollForm,
StickerPicker,
ScopeSelector
},
mounted () {
@ -84,8 +82,7 @@ const PostStatusForm = {
contentType
},
caret: 0,
pollFormVisible: false,
stickerPickerVisible: false
pollFormVisible: false
}
},
computed: {
@ -161,12 +158,6 @@ const PostStatusForm = {
safeDMEnabled () {
return this.$store.state.instance.safeDM
},
stickersAvailable () {
if (this.$store.state.instance.stickers) {
return this.$store.state.instance.stickers.length > 0
}
return 0
},
pollsAvailable () {
return this.$store.state.instance.pollsAvailable &&
this.$store.state.instance.pollLimits.max_options >= 2
@ -222,7 +213,6 @@ const PostStatusForm = {
poll: {}
}
this.pollFormVisible = false
this.stickerPickerVisible = false
this.$refs.mediaUpload.clearFile()
this.clearPollForm()
this.$emit('posted')
@ -239,7 +229,6 @@ const PostStatusForm = {
addMediaFile (fileInfo) {
this.newStatus.files.push(fileInfo)
this.enableSubmit()
this.stickerPickerVisible = false
},
removeMediaFile (fileInfo) {
let index = this.newStatus.files.indexOf(fileInfo)
@ -293,20 +282,16 @@ const PostStatusForm = {
target.style.height = null
}
},
showEmoji () {
this.$refs['textarea'].focus()
this.$refs['emoji-input'].triggerShowPicker()
},
clearError () {
this.error = null
},
changeVis (visibility) {
this.newStatus.visibility = visibility
},
toggleStickerPicker () {
this.stickerPickerVisible = !this.stickerPickerVisible
},
clearStickerPicker () {
if (this.$refs.stickerPicker) {
this.$refs.stickerPicker.clear()
}
},
togglePollForm () {
this.pollFormVisible = !this.pollFormVisible
},

View file

@ -74,10 +74,15 @@
>
</EmojiInput>
<EmojiInput
ref="emoji-input"
v-model="newStatus.status"
:suggest="emojiUserSuggestor"
emoji-picker
class="form-control main-input"
emoji-picker
emoji-picker-external-trigger
sticker-picker
@sticker-uploaded="addMediaFile"
@sticker-upload-failed="uploadFailed"
>
<textarea
ref="textarea"
@ -160,14 +165,12 @@
@upload-failed="uploadFailed"
/>
<div
v-if="stickersAvailable"
class="sticker-icon"
class="emoji-icon"
>
<i
:title="$t('stickers.add_sticker')"
class="icon-picture btn btn-default"
:class="{ selected: stickerPickerVisible }"
@click="toggleStickerPicker"
:title="$t('emoji.add_emoji')"
class="icon-smile btn btn-default"
@click.stop.prevent="showEmoji"
/>
</div>
<div
@ -260,11 +263,6 @@
<label for="filesSensitive">{{ $t('post_status.attachments_sensitive') }}</label>
</div>
</form>
<sticker-picker
v-if="stickerPickerVisible"
ref="stickerPicker"
@uploaded="addMediaFile"
/>
</div>
</template>
@ -327,7 +325,7 @@
}
}
.poll-icon, .sticker-icon {
.poll-icon, .emoji-icon {
font-size: 26px;
flex: 1;
@ -337,7 +335,7 @@
}
}
.sticker-icon {
.emoji-icon {
flex: 0;
min-width: 50px;
}