aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/admin_tabs/emoji_tab.js
diff options
context:
space:
mode:
authorEkaterina Vaartis <vaartis@kotobank.ch>2024-01-17 22:41:18 +0300
committerEkaterina Vaartis <vaartis@kotobank.ch>2024-01-18 16:24:55 +0300
commita2133f528333f5255296c15fb2b7abcab688bf1c (patch)
tree6db4e3183f0a53b6d95239f9d3a0bef10459d033 /src/components/settings_modal/admin_tabs/emoji_tab.js
parent872dffe51b4d96aafb2089917928f82d5a1350db (diff)
Rearrange stuff in accordance with comments on the MR, mostly
Also, add support for a custom message to the modified indicator
Diffstat (limited to 'src/components/settings_modal/admin_tabs/emoji_tab.js')
-rw-r--r--src/components/settings_modal/admin_tabs/emoji_tab.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.js b/src/components/settings_modal/admin_tabs/emoji_tab.js
index ed7ed797..940f0c6c 100644
--- a/src/components/settings_modal/admin_tabs/emoji_tab.js
+++ b/src/components/settings_modal/admin_tabs/emoji_tab.js
@@ -58,6 +58,11 @@ const EmojiTab = {
}
return result
+ },
+ newEmojiUploadPreview () {
+ if (this.newEmojiUpload.upload.length > 0) {
+ return URL.createObjectURL(this.newEmojiUpload.upload[0])
+ }
}
},
@@ -135,7 +140,11 @@ const EmojiTab = {
},
metaEdited (prop) {
- return this.pack && this.packMeta[prop] !== this.pack.pack[prop]
+ if (!this.pack) return
+
+ const def = this.pack.pack[prop] || ''
+ const edited = this.packMeta[prop] || ''
+ return edited !== def
},
savePackMetadata () {
this.$store.state.api.backendInteractor.saveEmojiPackMetadata({ name: this.packName, newData: this.packMeta }).then(
@@ -153,6 +162,11 @@ const EmojiTab = {
})
},
+ revertEmoji (shortcode) {
+ // Delete current changes and overwrite them with defaults. If the window is closed, they'll get cleared anyway
+ delete this.editedParts[this.packName][shortcode]
+ this.editEmoji(shortcode)
+ },
editEmoji (shortcode) {
if (this.editedParts[this.packName] === undefined) { this.editedParts[this.packName] = {} }
@@ -179,14 +193,22 @@ const EmojiTab = {
this.sortPackFiles(this.packName)
})
},
- saveEditedEmoji (shortcode) {
+ closedEditedEmoji (shortcode) {
const edited = this.editedParts[this.packName][shortcode]
if (edited.shortcode === shortcode && edited.file === this.pack.files[shortcode]) {
delete this.editedParts[this.packName][shortcode]
- return
+
+ return true
}
+ return false
+ },
+ saveEditedEmoji (shortcode) {
+ if (this.closedEditedEmoji(shortcode)) return
+
+ const edited = this.editedParts[this.packName][shortcode]
+
this.$store.state.api.backendInteractor.updateEmojiFile(
{ packName: this.packName, shortcode, newShortcode: edited.shortcode, newFilename: edited.file, force: false }
).then(resp => {