feat: support custom emojis from other servers

This commit is contained in:
Anthony Fu 2022-11-23 07:42:20 +08:00
parent f3a0a5af3f
commit 6d66bbbc5d
10 changed files with 40 additions and 16 deletions

View file

@ -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]))
}