Fix deleting last items on page

This commit is contained in:
Angelina Filippova 2020-06-26 00:05:55 +03:00
parent fbcc5ee524
commit dca1f2cce8
3 changed files with 15 additions and 6 deletions

View file

@ -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)
})
}

View file

@ -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)

View file

@ -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) {