2019-07-25 05:35:52 +10:00
|
|
|
/* eslint-env browser */
|
|
|
|
import statusPosterService from '../../services/status_poster/status_poster.service.js'
|
|
|
|
import TabSwitcher from '../tab_switcher/tab_switcher.js'
|
|
|
|
|
|
|
|
const StickerPicker = {
|
2019-08-13 03:01:38 +10:00
|
|
|
components: {
|
2019-07-25 05:35:52 +10:00
|
|
|
TabSwitcher
|
2019-08-13 03:01:38 +10:00
|
|
|
},
|
2019-07-25 05:35:52 +10:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
meta: {
|
|
|
|
stickers: []
|
|
|
|
},
|
|
|
|
path: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
pack () {
|
|
|
|
return this.$store.state.instance.stickers || []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clear () {
|
|
|
|
this.meta = {
|
|
|
|
stickers: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pick (sticker, name) {
|
|
|
|
const store = this.$store
|
|
|
|
// TODO remove this workaround by finding a way to bypass reuploads
|
|
|
|
fetch(sticker)
|
|
|
|
.then((res) => {
|
|
|
|
res.blob().then((blob) => {
|
|
|
|
var file = new File([blob], name, { mimetype: 'image/png' })
|
|
|
|
var formData = new FormData()
|
|
|
|
formData.append('file', file)
|
|
|
|
statusPosterService.uploadMedia({ store, formData })
|
|
|
|
.then((fileData) => {
|
|
|
|
this.$emit('uploaded', fileData)
|
|
|
|
this.clear()
|
|
|
|
}, (error) => {
|
|
|
|
console.warn("Can't attach sticker")
|
|
|
|
console.warn(error)
|
|
|
|
this.$emit('upload-failed', 'default')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default StickerPicker
|