diff options
| author | Shpuld Shpludson <shp@cock.li> | 2019-07-26 12:44:32 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2019-07-26 12:44:32 +0000 |
| commit | d3f6b581d1bbe64d26fceae3f00e9d471ca44dfe (patch) | |
| tree | 371e786ac95c83d914aa04f22aa9aabfb7b5dc4a /src/components/sticker_picker/sticker_picker.js | |
| parent | 3370dd80dc4644f2bff053b97b18698cd2abb550 (diff) | |
| parent | 4827e4d972f8ee11e606693e24ae4ca21711c6b1 (diff) | |
Merge branch 'develop' into 'feat/conversation-muting'
# Conflicts:
# src/components/extra_buttons/extra_buttons.js
# src/components/extra_buttons/extra_buttons.vue
Diffstat (limited to 'src/components/sticker_picker/sticker_picker.js')
| -rw-r--r-- | src/components/sticker_picker/sticker_picker.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/components/sticker_picker/sticker_picker.js b/src/components/sticker_picker/sticker_picker.js new file mode 100644 index 00000000..a6dcded3 --- /dev/null +++ b/src/components/sticker_picker/sticker_picker.js @@ -0,0 +1,52 @@ +/* eslint-env browser */ +import statusPosterService from '../../services/status_poster/status_poster.service.js' +import TabSwitcher from '../tab_switcher/tab_switcher.js' + +const StickerPicker = { + components: [ + TabSwitcher + ], + 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 |
