Use current page when fetching local emoji packs

This commit is contained in:
Angelina Filippova 2020-06-20 01:51:06 +03:00
parent 918bd18b88
commit a6a92d34ad
4 changed files with 16 additions and 6 deletions

View file

@ -40,6 +40,9 @@ const emojiPacks = {
SET_PACK_FILES: (state, { name, files }) => {
state.localPacks = { ...state.localPacks, [name]: { ...state.localPacks[name], files }}
},
SET_PAGE: (state, page) => {
state.currentPage = page
},
SET_REMOTE_INSTANCE: (state, name) => {
state.remoteInstance = name
},
@ -119,6 +122,7 @@ const emojiPacks = {
}, {})
commit('SET_LOCAL_PACKS', updatedPacks)
commit('SET_LOCAL_PACKS_COUNT', count)
commit('SET_PAGE', page)
},
async FetchSinglePack({ getters, commit }, name) {
const { data } = await fetchPack(name, getters.authHost, getters.token)

View file

@ -89,6 +89,9 @@ export default {
}
},
computed: {
currentPage() {
return this.$store.state.emojiPacks.currentPage
},
isMobile() {
return this.$store.state.app.device === 'mobile'
},
@ -174,12 +177,12 @@ export default {
}).then(() => {
this.$store.dispatch('DeletePack', { name: this.name })
.then(() => this.$store.dispatch('ReloadEmoji'))
.then(() => this.$store.dispatch('SetLocalEmojiPacks'))
.then(() => this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage))
}).catch(() => {})
},
handleChange(openTabs, name) {
if (openTabs.includes('manageEmoji')) {
this.$store.dispatch('FetchPack', name)
this.$store.dispatch('FetchSinglePack', name)
}
},
savePackMetadata() {

View file

@ -92,6 +92,9 @@ export default {
}
},
computed: {
currentPage() {
return this.$store.state.emojiPacks.currentPage
},
isDesktop() {
return this.$store.state.app.device === 'desktop'
},
@ -179,7 +182,7 @@ export default {
'DownloadFrom',
{ instanceAddress: this.remoteInstanceAddress, packName: this.name, as: this.downloadSharedAs }
).then(() => this.$store.dispatch('ReloadEmoji'))
.then(() => this.$store.dispatch('SetLocalEmojiPacks'))
.then(() => this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage))
}
}
}

View file

@ -143,7 +143,7 @@ export default {
.then(() => {
this.newPackName = ''
this.$store.dispatch('FetchLocalEmojiPacks')
this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage)
this.$store.dispatch('ReloadEmoji')
})
},
@ -153,13 +153,13 @@ export default {
importFromFS() {
this.$store.dispatch('ImportFromFS')
.then(() => {
this.$store.dispatch('FetchLocalEmojiPacks')
this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage)
this.$store.dispatch('ReloadEmoji')
})
},
refreshLocalPacks() {
try {
this.$store.dispatch('FetchLocalEmojiPacks', 1)
this.$store.dispatch('FetchLocalEmojiPacks', this.currentPage)
} catch (e) {
return
}