logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

sticker_picker.js (1321B)


  1. /* eslint-env browser */
  2. import statusPosterService from '../../services/status_poster/status_poster.service.js'
  3. import TabSwitcher from '../tab_switcher/tab_switcher.jsx'
  4. const StickerPicker = {
  5. components: {
  6. TabSwitcher
  7. },
  8. data () {
  9. return {
  10. meta: {
  11. stickers: []
  12. },
  13. path: ''
  14. }
  15. },
  16. computed: {
  17. pack () {
  18. return this.$store.state.instance.stickers || []
  19. }
  20. },
  21. methods: {
  22. clear () {
  23. this.meta = {
  24. stickers: []
  25. }
  26. },
  27. pick (sticker, name) {
  28. const store = this.$store
  29. // TODO remove this workaround by finding a way to bypass reuploads
  30. fetch(sticker)
  31. .then((res) => {
  32. res.blob().then((blob) => {
  33. const file = new File([blob], name, { mimetype: 'image/png' })
  34. const formData = new FormData()
  35. formData.append('file', file)
  36. statusPosterService.uploadMedia({ store, formData })
  37. .then((fileData) => {
  38. this.$emit('uploaded', fileData)
  39. this.clear()
  40. }, (error) => {
  41. console.warn("Can't attach sticker")
  42. console.warn(error)
  43. this.$emit('upload-failed', 'default')
  44. })
  45. })
  46. })
  47. }
  48. }
  49. }
  50. export default StickerPicker