diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js index 55fd1182..4edb722b 100644 --- a/src/api/emojiPacks.js +++ b/src/api/emojiPacks.js @@ -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) }) } diff --git a/src/store/modules/emojiPacks.js b/src/store/modules/emojiPacks.js index e16cdab9..1ada57b9 100644 --- a/src/store/modules/emojiPacks.js +++ b/src/store/modules/emojiPacks.js @@ -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) diff --git a/src/views/emojiPacks/components/LocalEmojiPack.vue b/src/views/emojiPacks/components/LocalEmojiPack.vue index 729ac49d..8f401756 100644 --- a/src/views/emojiPacks/components/LocalEmojiPack.vue +++ b/src/views/emojiPacks/components/LocalEmojiPack.vue @@ -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) {