feat: support custom emojis from other servers
This commit is contained in:
parent
f3a0a5af3f
commit
6d66bbbc5d
10 changed files with 40 additions and 16 deletions
|
@ -1,3 +1,4 @@
|
|||
import { emojisArrayToObject } from './utils'
|
||||
import type { ServerInfo } from '~/types'
|
||||
|
||||
const ServerInfoTTL = 60 * 60 * 1000 * 12 // 12 hour
|
||||
|
@ -19,7 +20,7 @@ async function _fetchServerInfo(server: string) {
|
|||
Object.assign(serverInfos.value[server], r)
|
||||
}),
|
||||
masto.customEmojis.fetchAll().then((r) => {
|
||||
serverInfos.value[server].customEmojis = Object.fromEntries(r.map(i => [i.shortcode, i]))
|
||||
serverInfos.value[server].customEmojis = emojisArrayToObject(r)
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import type { Emoji } from 'masto'
|
||||
|
||||
export function getDataUrlFromArr(arr: Uint8ClampedArray, w: number, h: number) {
|
||||
if (typeof w === 'undefined' || typeof h === 'undefined')
|
||||
w = h = Math.sqrt(arr.length / 4)
|
||||
|
@ -14,3 +16,7 @@ export function getDataUrlFromArr(arr: Uint8ClampedArray, w: number, h: number)
|
|||
|
||||
return canvas.toDataURL()
|
||||
}
|
||||
|
||||
export function emojisArrayToObject(emojis: Emoji[]) {
|
||||
return Object.fromEntries(emojis.map(i => [i.shortcode, i]))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue