Skip to content
Snippets Groups Projects
Commit a6a92d34 authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Use current page when fetching local emoji packs

parent 918bd18b
No related branches found
No related tags found
1 merge request!137Implement emoji packs pagination
Pipeline #27457 passed
......@@ -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)
......
......@@ -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() {
......
......@@ -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))
}
}
}
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment