diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.js b/src/components/settings_modal/admin_tabs/emoji_tab.js
index f3adc3d53..d88c9e55a 100644
--- a/src/components/settings_modal/admin_tabs/emoji_tab.js
+++ b/src/components/settings_modal/admin_tabs/emoji_tab.js
@@ -24,13 +24,16 @@ const EmojiTab = {
data () {
return {
- knownPacks: { },
+ knownLocalPacks: { },
+ knownRemotePacks: { },
editedParts: { },
editedMetadata: { },
packName: '',
newPackName: '',
deleteModalVisible: false,
- newEmojiUpload: clone(newEmojiUploadBase)
+ newEmojiUpload: clone(newEmojiUploadBase),
+ remotePackInstance: '',
+ remotePackDownloadAs: ''
}
},
@@ -44,6 +47,17 @@ const EmojiTab = {
}
return this.editedMetadata[this.packName]
+ },
+ knownPacks () {
+ // Copy the object itself but not the children, so they are still passed by reference and modified
+ const result = clone(this.knownLocalPacks)
+ for (const instName in this.knownRemotePacks) {
+ for (const instPack in this.knownRemotePacks[instName]) {
+ result[`${instPack}@${instName}`] = this.knownRemotePacks[instName][instPack]
+ }
+ }
+
+ return result
}
},
@@ -55,7 +69,12 @@ const EmojiTab = {
this.$store.state.api.backendInteractor.importEmojiFromFS()
},
emojiAddr (name) {
- return `${this.$store.state.instance.server}/emoji/${encodeURIComponent(this.packName)}/${name}`
+ if (this.pack.remote !== undefined) {
+ // Remote pack
+ return `${this.pack.remote.instance}/emoji/${encodeURIComponent(this.pack.remote.baseName)}/${name}`
+ } else {
+ return `${this.$store.state.instance.server}/emoji/${encodeURIComponent(this.packName)}/${name}`
+ }
},
uploadEmoji () {
@@ -193,15 +212,64 @@ const EmojiTab = {
return
}
- this.knownPacks = packData.packs
- for (const name of Object.keys(this.knownPacks)) {
+ this.knownLocalPacks = packData.packs
+ for (const name of Object.keys(this.knownLocalPacks)) {
this.sortPackFiles(name)
}
})
},
+ listRemotePacks () {
+ this.$store.state.api.backendInteractor.listRemoteEmojiPacks({ instance: this.remotePackInstance })
+ .then(data => data.json())
+ .then(packData => {
+ if (packData.error !== undefined) {
+ this.displayError(packData.error)
+ return
+ }
+
+ let inst = this.remotePackInstance
+ if (!inst.startsWith('http')) { inst = 'https://' + inst }
+ const instUrl = new URL(inst)
+ inst = instUrl.host
+
+ for (const packName in packData.packs) {
+ packData.packs[packName].remote = {
+ baseName: packName,
+ instance: instUrl.origin
+ }
+ }
+
+ this.knownRemotePacks[inst] = packData.packs
+
+ this.$refs.remotePackPopover.hidePopover()
+ })
+ },
+ downloadRemotePack () {
+ if (this.remotePackDownloadAs.trim() === '') {
+ this.remotePackDownloadAs = this.pack.remote.baseName
+ }
+
+ this.$store.state.api.backendInteractor.downloadRemoteEmojiPack({
+ instance: this.pack.remote.instance, packName: this.pack.remote.baseName, as: this.remotePackDownloadAs
+ })
+ .then(data => data.json())
+ .then(resp => {
+ if (resp === 'ok') {
+ this.$refs.dlPackPopover.hidePopover()
+
+ return this.refreshPackList()
+ } else {
+ this.displayError(resp.error)
+ return Promise.reject(resp)
+ }
+ }).then(done => {
+ this.packName = this.remotePackDownloadAs
+ this.remotePackDownloadAs = ''
+ })
+ },
displayError (msg) {
this.$store.dispatch('pushGlobalNotice', {
- messageKey: 'upload.error.message',
+ messageKey: 'admin_dash.emoji.error',
messageArgs: [msg],
level: 'error'
})
diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.vue b/src/components/settings_modal/admin_tabs/emoji_tab.vue
index cdde95c39..860eaddd9 100644
--- a/src/components/settings_modal/admin_tabs/emoji_tab.vue
+++ b/src/components/settings_modal/admin_tabs/emoji_tab.vue
@@ -27,7 +27,7 @@
class="button button-default btn"
type="button"
@click="$refs.createPackPopover.showPopover">
- Create pack
+ {{ $t('admin_dash.emoji.create_pack') }}