pleroma-fe/src/components/sticker_picker/sticker_picker.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

/* eslint-env browser */
import { useInstanceStore } from 'src/stores/instance.js'
import statusPosterService from '../../services/status_poster/status_poster.service.js'
import TabSwitcher from '../tab_switcher/tab_switcher.jsx'
const StickerPicker = {
components: {
2026-01-06 16:22:52 +02:00
TabSwitcher,
},
2026-01-06 16:22:52 +02:00
data() {
return {
meta: {
2026-01-06 16:22:52 +02:00
stickers: [],
},
2026-01-06 16:22:52 +02:00
path: '',
}
},
computed: {
2026-01-06 16:22:52 +02:00
pack() {
2026-01-29 15:14:17 +02:00
return useEmojiStore().stickers || []
2026-01-06 16:22:52 +02:00
},
},
methods: {
2026-01-06 16:22:52 +02:00
clear() {
this.meta = {
2026-01-06 16:22:52 +02:00
stickers: [],
}
},
2026-01-06 16:22:52 +02:00
pick(sticker, name) {
const store = this.$store
// TODO remove this workaround by finding a way to bypass reuploads
2026-01-06 16:22:52 +02:00
fetch(sticker).then((res) => {
res.blob().then((blob) => {
const file = new File([blob], name, { mimetype: 'image/png' })
const 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')
},
)
})
2026-01-06 16:22:52 +02:00
})
},
},
}
export default StickerPicker