...
 
Commits (3)
......@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- On Reports page add links to reported account and the author of the report
- In Notes add link to the note author's profile page
- In Moderation log add link to the actor's profile page
- Support pagination of local emoji packs and files
### Changed
......
......@@ -37,10 +37,9 @@ export async function createPack(host, token, packName) {
export async function deleteEmojiFile(packName, shortcode, host, token) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`,
url: `/api/pleroma/emoji/packs/${packName}/files?shortcode=${shortcode}`,
method: 'delete',
headers: authHeaders(token),
data: { shortcode }
headers: authHeaders(token)
})
}
......@@ -53,17 +52,15 @@ export async function deletePack(host, token, packName) {
})
}
export async function downloadFrom(host, instance, packName, as, token) {
if (as.trim() === '') {
as = null
}
export async function downloadFrom(instanceAddress, packName, as, host, token) {
return await request({
baseURL: baseName(host),
url: '/api/pleroma/emoji/packs/download',
method: 'post',
headers: authHeaders(token),
data: { url: baseName(instance), name: packName, as },
data: as.trim() === ''
? { url: baseName(instanceAddress), name: packName }
: { url: baseName(instanceAddress), name: packName, as },
timeout: 0
})
}
......
......@@ -103,8 +103,11 @@ const emojiPacks = {
type: 'success',
duration: 5 * 1000
})
dispatch('FetchSinglePack', { name: packName, page: state.currentFilesPage })
if (Object.keys(updatedPackFiles).length === 0 && state.currentFilesPage > 1) {
dispatch('FetchSinglePack', { name: packName, page: state.currentFilesPage - 1 })
} else {
dispatch('FetchSinglePack', { name: packName, page: state.currentFilesPage })
}
},
async CreatePack({ getters }, { name }) {
await createPack(getters.authHost, getters.token, name)
......@@ -113,7 +116,7 @@ const emojiPacks = {
await deletePack(getters.authHost, getters.token, name)
},
async DownloadFrom({ getters }, { instanceAddress, packName, as }) {
const result = await downloadFrom(getters.authHost, instanceAddress, packName, as, getters.token)
const result = await downloadFrom(instanceAddress, packName, as, getters.authHost, getters.token)
if (result.data === 'ok') {
Message({
......
......@@ -195,7 +195,14 @@ export default {
}).then(() => {
this.$store.dispatch('DeletePack', { name: this.name })
.then(() => this.$store.dispatch('ReloadEmoji'))
.then(() => this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage))
.then(() => {
const { [this.name]: value, ...updatedPacks } = this.$store.state.emojiPacks.localPacks
if (Object.keys(updatedPacks).length === 0 && this.currentPage > 1) {
this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage - 1)
} else {
this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage)
}
})
}).catch(() => {})
},
handleChange(openTabs, name) {
......
......@@ -24,7 +24,7 @@
</el-form-item>
<el-form-item>
<el-link
v-if="pack.pack['can-download']"
v-if="pack.pack['can-download'] && pack.pack['fallback-src']"
:href="pack.pack['fallback-src']"
:underline="false"
type="primary"
......