Merge branch 'remote-listing' into 'master'
More annoying fixes for the emoji packs See merge request pleroma/admin-fe!48
This commit is contained in:
commit
21a7aa0de5
3 changed files with 23 additions and 5 deletions
|
@ -48,6 +48,16 @@ export async function listPacks(host) {
|
|||
})
|
||||
}
|
||||
|
||||
export async function listRemotePacks(host, token, instance) {
|
||||
return await request({
|
||||
baseURL: baseName(host),
|
||||
url: `/api/pleroma/emoji/packs/list_from`,
|
||||
method: 'post',
|
||||
headers: authHeaders(token),
|
||||
data: { instance_address: baseName(instance) }
|
||||
})
|
||||
}
|
||||
|
||||
export async function downloadFrom(host, instance_address, pack_name, as, token) {
|
||||
if (as.trim() === '') {
|
||||
as = null
|
||||
|
@ -58,7 +68,7 @@ export async function downloadFrom(host, instance_address, pack_name, as, token)
|
|||
url: '/api/pleroma/emoji/packs/download_from',
|
||||
method: 'post',
|
||||
headers: authHeaders(token),
|
||||
data: { instance_address, pack_name, as },
|
||||
data: { instance_address: baseName(instance_address), pack_name, as },
|
||||
timeout: 0
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
const isLocalhost = (instanceName) =>
|
||||
instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:')
|
||||
|
||||
export const baseName = (instanceName) =>
|
||||
isLocalhost(instanceName) ? `http://${instanceName}` : `https://${instanceName}`
|
||||
export const baseName = (instanceName) => {
|
||||
if (instanceName.match(/https?:\/\//)) {
|
||||
return instanceName
|
||||
} else {
|
||||
return isLocalhost(instanceName) ? `http://${instanceName}` : `https://${instanceName}`
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { listPacks,
|
||||
import {
|
||||
listPacks,
|
||||
listRemotePacks,
|
||||
downloadFrom,
|
||||
reloadEmoji,
|
||||
createPack,
|
||||
|
@ -47,7 +49,8 @@ const packs = {
|
|||
commit('SET_LOCAL_PACKS', data)
|
||||
},
|
||||
async SetRemoteEmojiPacks({ commit, getters, state }, { remoteInstance }) {
|
||||
const { data } = await listPacks(remoteInstance)
|
||||
const { data } = await listRemotePacks(getters.authHost, getters.token, remoteInstance)
|
||||
|
||||
commit('SET_REMOTE_PACKS', data)
|
||||
},
|
||||
async DownloadFrom({ commit, getters, state }, { instanceAddress, packName, as }) {
|
||||
|
|
Loading…
Reference in a new issue