From c2fc99bce002f2d8994a4813db7f6f7c665b4258 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 19 Jun 2020 02:09:10 +0300 Subject: [PATCH 01/15] Fetch local pack's files only after opening collapse item to manage emojis --- src/lang/en.js | 3 +- src/store/modules/emojiPacks.js | 17 ++++++++-- .../emojiPacks/components/LocalEmojiPack.vue | 32 +++++++++++++------ src/views/emojiPacks/index.vue | 9 ++---- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 2ef9a89c..16ff35f2 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -475,6 +475,7 @@ export default { specifyShortcode: 'Specify a custom shortcode', specifyFilename: 'Specify a custom filename', copy: 'Copy', - copyToLocalPack: 'Copy to local pack' + copyToLocalPack: 'Copy to local pack', + emptyPack: 'This emoji pack is empty' } } diff --git a/src/store/modules/emojiPacks.js b/src/store/modules/emojiPacks.js index e4748c26..c809dbf1 100644 --- a/src/store/modules/emojiPacks.js +++ b/src/store/modules/emojiPacks.js @@ -4,6 +4,7 @@ import { deleteEmojiFile, deletePack, downloadFrom, + fetchPack, importFromFS, listPacks, listRemotePacks, @@ -30,6 +31,9 @@ const packs = { SET_LOCAL_PACKS: (state, packs) => { state.localPacks = packs }, + SET_PACK_FILES: (state, { name, files }) => { + state.localPacks = { ...state.localPacks, [name]: { ...state.localPacks[name], files }} + }, SET_REMOTE_INSTANCE: (state, name) => { state.remoteInstance = name }, @@ -99,6 +103,10 @@ const packs = { }) } }, + async FetchPack({ getters, commit }, name) { + const { data } = await fetchPack(name, getters.authHost, getters.token) + commit('SET_PACK_FILES', { name, files: data.files }) + }, async ImportFromFS({ getters }) { const result = await importFromFS(getters.authHost, getters.token) @@ -136,12 +144,17 @@ const packs = { commit('UPDATE_LOCAL_PACK_PACK', { name: packName, pack: result.data }) } }, - SetActiveCollapseItems({ commit, state }, activeItems) { + SetActiveCollapseItems({ commit }, activeItems) { commit('SET_ACTIVE_COLLAPSE_ITEMS', activeItems) }, async SetLocalEmojiPacks({ commit, getters }) { const { data } = await listPacks(getters.authHost) - commit('SET_LOCAL_PACKS', data) + const packs = Object.keys(data).reduce((acc, packName) => { + const { files, ...pack } = data[packName] + acc[packName] = pack + return acc + }, {}) + commit('SET_LOCAL_PACKS', packs) }, async SetRemoteEmojiPacks({ commit, getters }, { remoteInstance }) { const { data } = await listRemotePacks(getters.authHost, getters.token, remoteInstance) diff --git a/src/views/emojiPacks/components/LocalEmojiPack.vue b/src/views/emojiPacks/components/LocalEmojiPack.vue index 1cf4bdae..cdf9a5c5 100644 --- a/src/views/emojiPacks/components/LocalEmojiPack.vue +++ b/src/views/emojiPacks/components/LocalEmojiPack.vue @@ -38,19 +38,22 @@ - + - - + +
+ +
+ {{ $t('emoji.emptyPack') }}
@@ -101,6 +104,10 @@ export default { return '155px' } }, + sortedFiles() { + return Object.keys(this.pack.files).sort((a, b) => a.localeCompare(b)) + .map(key => [key, this.pack.files[key]]) + }, share: { get() { return this.pack.pack['share-files'] }, set(value) { @@ -170,6 +177,11 @@ export default { .then(() => this.$store.dispatch('SetLocalEmojiPacks')) }).catch(() => {}) }, + handleChange(openTabs, name) { + if (openTabs.includes('manageEmoji')) { + this.$store.dispatch('FetchPack', name) + } + }, savePackMetadata() { this.$store.dispatch('SavePackMetadata', { packName: this.name }) } diff --git a/src/views/emojiPacks/index.vue b/src/views/emojiPacks/index.vue index c9173f43..14811828 100644 --- a/src/views/emojiPacks/index.vue +++ b/src/views/emojiPacks/index.vue @@ -31,8 +31,8 @@ - - + + @@ -128,11 +128,6 @@ export default { this.$store.dispatch('ReloadEmoji') }) }, - sortPack(pack) { - const orderedFiles = Object.keys(pack.files).sort((a, b) => a.localeCompare(b)) - .map(key => [key, pack.files[key]]) - return { ...pack, files: orderedFiles } - }, refreshLocalPacks() { try { this.$store.dispatch('SetLocalEmojiPacks') From 51020a6699816b3c96ade522bd609bc810e2c0ee Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 19 Jun 2020 02:55:15 +0300 Subject: [PATCH 02/15] Rename Emoji packs module --- src/store/index.js | 10 +++++----- src/store/modules/emojiPacks.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 586f2b07..e2fcd651 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,9 +1,11 @@ import Vue from 'vue' import Vuex from 'vuex' import app from './modules/app' +import emojiPacks from './modules/emojiPacks' import errorLog from './modules/errorLog' -import moderationLog from './modules/moderationLog' +import getters from './getters' import invites from './modules/invites' +import moderationLog from './modules/moderationLog' import peers from './modules/peers' import permission from './modules/permission' import relays from './modules/relays' @@ -14,8 +16,6 @@ import tagsView from './modules/tagsView' import user from './modules/user' import userProfile from './modules/userProfile' import users from './modules/users' -import getters from './getters' -import emojiPacks from './modules/emojiPacks.js' Vue.use(Vuex) @@ -23,6 +23,7 @@ const store = new Vuex.Store({ modules: { app, errorLog, + emojiPacks, moderationLog, invites, peers, @@ -34,8 +35,7 @@ const store = new Vuex.Store({ tagsView, user, userProfile, - users, - emojiPacks + users }, getters }) diff --git a/src/store/modules/emojiPacks.js b/src/store/modules/emojiPacks.js index c809dbf1..84a07105 100644 --- a/src/store/modules/emojiPacks.js +++ b/src/store/modules/emojiPacks.js @@ -17,7 +17,7 @@ import { Message } from 'element-ui' import Vue from 'vue' -const packs = { +const emojiPacks = { state: { activeCollapseItems: [], localPacks: {}, @@ -186,4 +186,4 @@ const packs = { } } -export default packs +export default emojiPacks From 8d23e36a542e64f4aea978e828a9d4bfc039d7f9 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 19 Jun 2020 21:40:08 +0300 Subject: [PATCH 03/15] Put managing local and remote packs on tabs --- src/views/emojiPacks/index.vue | 112 ++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/src/views/emojiPacks/index.vue b/src/views/emojiPacks/index.vue index 14811828..be05d2c4 100644 --- a/src/views/emojiPacks/index.vue +++ b/src/views/emojiPacks/index.vue @@ -6,56 +6,62 @@
- {{ $t('emoji.reloadEmoji') }} + {{ $t('emoji.reloadEmoji') }} - + {{ $t('emoji.importPacks') }}
- - - - {{ $t('emoji.refreshLocalPacks') }} - - -
- - - {{ $t('users.create') }} - -
-
- - - - - - - -
- - - {{ $t('emoji.refreshRemote') }} - -
-
- - - - - -
+ + + + + {{ $t('emoji.refreshLocalPacks') }} + + +
+ + + {{ $t('users.create') }} + +
+
+ + + + + +
+
+ + + +
+ + + {{ $t('emoji.refreshRemote') }} + +
+
+ + + + + +
+
+
@@ -69,6 +75,7 @@ export default { components: { LocalEmojiPack, RebootButton, RemoteEmojiPack }, data() { return { + activeTab: 'local', newPackName: '', activeLocalPack: [], activeRemotePack: [], @@ -164,6 +171,13 @@ export default {