Initial POC

This commit is contained in:
Alex 2024-01-06 17:04:16 -05:00
parent 8dce31d0ad
commit 334ec7175e
12 changed files with 237 additions and 119 deletions

View file

@ -177,22 +177,33 @@ const instance = {
async getCustomEmoji ({ commit, state }) {
try {
const res = await window.fetch('/api/v1/pleroma/emoji')
const res = await window.fetch('/api/emojis')
if (res.ok) {
const result = await res.json()
const values = Array.isArray(result) ? Object.assign({}, ...result) : result
const emoji = Object.entries(values).map(([key, value]) => {
const imageUrl = value.image_url
return {
displayText: key,
imageUrl: imageUrl ? state.server + imageUrl : value,
tags: imageUrl ? value.tags.sort((a, b) => a > b ? 1 : 0) : ['utf'],
replacement: `:${key}: `
}
// Technically could use tags but those are kinda useless right now,
// should have been "pack" field, that would be more useful
}).sort((a, b) => a.displayText.toLowerCase() > b.displayText.toLowerCase() ? 1 : -1)
commit('setInstanceOption', { name: 'customEmoji', value: emoji })
//const values = Array.isArray(result.emojis) ? Object.assign({}, ...result) : result
const values = result.emojis
var emoji = []
for ( var i = 0; i < values.length; i++) {
emoji.push({
displayText: values[i].name,
imageUrl: values[i].url,
replacement: values[i].name,
tags: ['sharkey']
})
}
// const emoji = Object.entries(values).map(([key, value]) => {
// const imageUrl = value.image_url
// return {
// displayText: key,
// imageUrl: imageUrl ? state.server + imageUrl : value,
// tags: imageUrl ? value.tags.sort((a, b) => a > b ? 1 : 0) : ['utf'],
// replacement: `:${key}: `
// }
// // Technically could use tags but those are kinda useless right now,
// // should have been "pack" field, that would be more useful
// }).sort((a, b) => a.displayText.toLowerCase() > b.displayText.toLowerCase() ? 1 : -1)
commit('setInstanceOption', { name: 'customEmoji', value: Object.assign(emoji) })
} else {
throw (res)
}