Update API for downloading remote packs
This commit is contained in:
parent
5805792211
commit
1f488a18be
4 changed files with 20 additions and 8 deletions
|
@ -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() === '') {
|
if (as.trim() === '') {
|
||||||
as = null
|
as = null
|
||||||
}
|
}
|
||||||
|
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(host),
|
baseURL: baseName(host),
|
||||||
url: '/api/pleroma/emoji/packs/download_from',
|
url: '/api/pleroma/emoji/packs/download',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: authHeaders(token),
|
headers: authHeaders(token),
|
||||||
data: { instance_address: baseName(instance_address), pack_name, as },
|
data: { url: baseName(instance), name: pack_name, as },
|
||||||
timeout: 0
|
timeout: 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,9 @@ const packs = {
|
||||||
commit('SET_REMOTE_INSTANCE', remoteInstance)
|
commit('SET_REMOTE_INSTANCE', remoteInstance)
|
||||||
commit('SET_REMOTE_PACKS', data)
|
commit('SET_REMOTE_PACKS', data)
|
||||||
},
|
},
|
||||||
|
SetRemoteInstance({ commit }, instance) {
|
||||||
|
commit('SET_REMOTE_INSTANCE', instance)
|
||||||
|
},
|
||||||
async UpdateAndSavePackFile({ commit, getters }, args) {
|
async UpdateAndSavePackFile({ commit, getters }, args) {
|
||||||
const result = await updatePackFile(getters.authHost, getters.token, args)
|
const result = await updatePackFile(getters.authHost, getters.token, args)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
</p>
|
</p>
|
||||||
<div class="download-shared-pack">
|
<div class="download-shared-pack">
|
||||||
<el-input v-model="downloadSharedAs" :placeholder=" $t('emoji.downloadAsOptional')"/>
|
<el-input v-model="downloadSharedAs" :placeholder=" $t('emoji.downloadAsOptional')"/>
|
||||||
<el-button type="primary" class="download-shared-pack-button" @click="downloadFromInstance(pack.pack['homepage'])">
|
<el-button type="primary" class="download-shared-pack-button" @click="downloadFromInstance">
|
||||||
{{ isDesktop ? $t('emoji.downloadSharedPack') : $t('emoji.downloadSharedPackMobile') }}
|
{{ isDesktop ? $t('emoji.downloadSharedPack') : $t('emoji.downloadSharedPackMobile') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -113,6 +113,9 @@ export default {
|
||||||
loadRemotePack() {
|
loadRemotePack() {
|
||||||
return this.$store.state.emojiPacks.activeCollapseItems.includes(this.name)
|
return this.$store.state.emojiPacks.activeCollapseItems.includes(this.name)
|
||||||
},
|
},
|
||||||
|
remoteInstanceAddress() {
|
||||||
|
return this.$store.state.emojiPacks.remoteInstance
|
||||||
|
},
|
||||||
share: {
|
share: {
|
||||||
get() { return this.pack.pack['share-files'] },
|
get() { return this.pack.pack['share-files'] },
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -171,11 +174,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
downloadFromInstance(url) {
|
downloadFromInstance() {
|
||||||
const instanceAddress = `${new URL(url).protocol}//${new URL(url).hostname}`
|
|
||||||
this.$store.dispatch(
|
this.$store.dispatch(
|
||||||
'DownloadFrom',
|
'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('ReloadEmoji'))
|
||||||
.then(() => this.$store.dispatch('SetLocalEmojiPacks'))
|
.then(() => this.$store.dispatch('SetLocalEmojiPacks'))
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,6 @@ export default {
|
||||||
components: { LocalEmojiPack, RemoteEmojiPack },
|
components: { LocalEmojiPack, RemoteEmojiPack },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
remoteInstanceAddress: '',
|
|
||||||
newPackName: '',
|
newPackName: '',
|
||||||
activeLocalPack: [],
|
activeLocalPack: [],
|
||||||
activeRemotePack: [],
|
activeRemotePack: [],
|
||||||
|
@ -89,6 +88,14 @@ export default {
|
||||||
localPacks() {
|
localPacks() {
|
||||||
return this.$store.state.emojiPacks.localPacks
|
return this.$store.state.emojiPacks.localPacks
|
||||||
},
|
},
|
||||||
|
remoteInstanceAddress: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.emojiPacks.remoteInstance
|
||||||
|
},
|
||||||
|
set(instance) {
|
||||||
|
this.$store.dispatch('SetRemoteInstance', instance)
|
||||||
|
}
|
||||||
|
},
|
||||||
remotePacks() {
|
remotePacks() {
|
||||||
return this.$store.state.emojiPacks.remotePacks
|
return this.$store.state.emojiPacks.remotePacks
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue