1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
import StringSetting from '../helpers/string_setting.vue'
import Checkbox from 'components/checkbox/checkbox.vue'
import StillImage from 'components/still-image/still-image.vue'
const EmojiTab = {
components: {
TabSwitcher,
StringSetting,
Checkbox,
StillImage
},
data () {
return {
knownPacks: { },
editedParts: { }
}
},
methods: {
reloadEmoji () {
this.$store.state.api.backendInteractor.reloadEmoji()
},
importFromFS () {
this.$store.state.api.backendInteractor.importEmojiFromFS()
},
emojiAddr (packName, name) {
return `${this.$store.state.instance.server}/emoji/${encodeURIComponent(packName)}/${name}`
},
editEmoji (packName, shortcode) {
if (this.editedParts[packName] === undefined) { this.editedParts[packName] = {} }
this.editedParts[packName][shortcode] = {
shortcode, file: this.knownPacks[packName].files[shortcode]
}
},
saveEditedEmoji (packName, shortcode) {
const edited = this.editedParts[packName][shortcode]
this.$store.state.api.backendInteractor.updateEmojiFile(
{ packName, shortcode, newShortcode: edited.shortcode, newFilename: edited.file, force: false }
).then(resp =>
resp.ok ? resp.json() : resp.text().then(respText => Promise.reject(respText))
).then(resp => {
this.knownPacks[packName].files = resp
delete this.editedParts[packName][shortcode]
})
}
},
mounted () {
this.$store.state.api.backendInteractor.listEmojiPacks()
.then(data => data.json())
.then(packData => {
this.knownPacks = packData.packs
console.log(this.knownPacks)
})
}
}
export default EmojiTab
|