From a6a92d34ad0f8fa5eb5a6368264de977772cc334 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 20 Jun 2020 01:51:06 +0300 Subject: [PATCH] Use current page when fetching local emoji packs --- src/store/modules/emojiPacks.js | 4 ++++ src/views/emojiPacks/components/LocalEmojiPack.vue | 7 +++++-- src/views/emojiPacks/components/RemoteEmojiPack.vue | 5 ++++- src/views/emojiPacks/index.vue | 6 +++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/store/modules/emojiPacks.js b/src/store/modules/emojiPacks.js index 9a0e7dbc..4f59afb4 100644 --- a/src/store/modules/emojiPacks.js +++ b/src/store/modules/emojiPacks.js @@ -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) diff --git a/src/views/emojiPacks/components/LocalEmojiPack.vue b/src/views/emojiPacks/components/LocalEmojiPack.vue index cdf9a5c5..13033503 100644 --- a/src/views/emojiPacks/components/LocalEmojiPack.vue +++ b/src/views/emojiPacks/components/LocalEmojiPack.vue @@ -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() { diff --git a/src/views/emojiPacks/components/RemoteEmojiPack.vue b/src/views/emojiPacks/components/RemoteEmojiPack.vue index 3ae2af5d..c83db513 100644 --- a/src/views/emojiPacks/components/RemoteEmojiPack.vue +++ b/src/views/emojiPacks/components/RemoteEmojiPack.vue @@ -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)) } } } diff --git a/src/views/emojiPacks/index.vue b/src/views/emojiPacks/index.vue index a4c5b19e..885c9ff3 100644 --- a/src/views/emojiPacks/index.vue +++ b/src/views/emojiPacks/index.vue @@ -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 }