From 1f488a18be94f116b1c1a61e892c69445ed831bd Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 30 Mar 2020 19:48:41 +0300 Subject: [PATCH] Update API for downloading remote packs --- src/api/emojiPacks.js | 6 +++--- src/store/modules/emojiPacks.js | 3 +++ src/views/emojiPacks/components/RemoteEmojiPack.vue | 10 ++++++---- src/views/emojiPacks/index.vue | 9 ++++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js index d2093280..22d8f7ad 100644 --- a/src/api/emojiPacks.js +++ b/src/api/emojiPacks.js @@ -57,17 +57,17 @@ export async function listRemotePacks(host, token, instance) { }) } -export async function downloadFrom(host, instance_address, pack_name, as, token) { +export async function downloadFrom(host, instance, pack_name, as, token) { if (as.trim() === '') { as = null } return await request({ baseURL: baseName(host), - url: '/api/pleroma/emoji/packs/download_from', + url: '/api/pleroma/emoji/packs/download', method: 'post', headers: authHeaders(token), - data: { instance_address: baseName(instance_address), pack_name, as }, + data: { url: baseName(instance), name: pack_name, as }, timeout: 0 }) } diff --git a/src/store/modules/emojiPacks.js b/src/store/modules/emojiPacks.js index f92e0fa5..3b376769 100644 --- a/src/store/modules/emojiPacks.js +++ b/src/store/modules/emojiPacks.js @@ -116,6 +116,9 @@ const packs = { commit('SET_REMOTE_INSTANCE', remoteInstance) commit('SET_REMOTE_PACKS', data) }, + SetRemoteInstance({ commit }, instance) { + commit('SET_REMOTE_INSTANCE', instance) + }, async UpdateAndSavePackFile({ commit, getters }, args) { const result = await updatePackFile(getters.authHost, getters.token, args) diff --git a/src/views/emojiPacks/components/RemoteEmojiPack.vue b/src/views/emojiPacks/components/RemoteEmojiPack.vue index 0c9ecaf3..be1bc858 100644 --- a/src/views/emojiPacks/components/RemoteEmojiPack.vue +++ b/src/views/emojiPacks/components/RemoteEmojiPack.vue @@ -52,7 +52,7 @@

- + {{ isDesktop ? $t('emoji.downloadSharedPack') : $t('emoji.downloadSharedPackMobile') }}
@@ -113,6 +113,9 @@ export default { loadRemotePack() { return this.$store.state.emojiPacks.activeCollapseItems.includes(this.name) }, + remoteInstanceAddress() { + return this.$store.state.emojiPacks.remoteInstance + }, share: { get() { return this.pack.pack['share-files'] }, set(value) { @@ -171,11 +174,10 @@ export default { } }, methods: { - downloadFromInstance(url) { - const instanceAddress = `${new URL(url).protocol}//${new URL(url).hostname}` + downloadFromInstance() { this.$store.dispatch( 'DownloadFrom', - { instanceAddress, packName: this.name, as: this.downloadSharedAs } + { instanceAddress: this.remoteInstanceAddress, packName: this.name, as: this.downloadSharedAs } ).then(() => this.$store.dispatch('ReloadEmoji')) .then(() => this.$store.dispatch('SetLocalEmojiPacks')) } diff --git a/src/views/emojiPacks/index.vue b/src/views/emojiPacks/index.vue index 8154f254..7c4539b5 100644 --- a/src/views/emojiPacks/index.vue +++ b/src/views/emojiPacks/index.vue @@ -63,7 +63,6 @@ export default { components: { LocalEmojiPack, RemoteEmojiPack }, data() { return { - remoteInstanceAddress: '', newPackName: '', activeLocalPack: [], activeRemotePack: [], @@ -89,6 +88,14 @@ export default { localPacks() { return this.$store.state.emojiPacks.localPacks }, + remoteInstanceAddress: { + get() { + return this.$store.state.emojiPacks.remoteInstance + }, + set(instance) { + this.$store.dispatch('SetRemoteInstance', instance) + } + }, remotePacks() { return this.$store.state.emojiPacks.remotePacks }