logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 6fab7b9e3ffb4a9bce2788174ef0e9e6eef7b2c5
parent cc58b9b93d4346860e244d2093f0d406eb76954c
Author: Tusooa Zhu <tusooa@kazv.moe>
Date:   Tue, 20 Sep 2022 22:03:31 -0400

Use import() for emoji.json

Diffstat:

Mbuild/update-emoji.js2+-
Mpackage.json1-
Msrc/modules/instance.js27++++++++++++---------------
Myarn.lock5-----
4 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/build/update-emoji.js b/build/update-emoji.js @@ -1,7 +1,7 @@ module.exports = { updateEmoji () { - const emojis = require('unicode-emoji-json/data-by-group') + const emojis = require('@kazvmoe-infra/unicode-emoji-json/data-by-group') const fs = require('fs') Object.keys(emojis) diff --git a/package.json b/package.json @@ -117,7 +117,6 @@ "stylelint": "13.13.1", "stylelint-config-standard": "20.0.0", "stylelint-rscss": "0.4.0", - "unicode-emoji-json": "^0.3.0", "vue-loader": "17.0.0", "vue-style-loader": "4.1.3", "webpack": "5.74.0", diff --git a/src/modules/instance.js b/src/modules/instance.js @@ -135,6 +135,7 @@ const loadAnnotations = (lang) => { return import( `@kazvmoe-infra/unicode-emoji-json/annotations/${langCodeToCldrName(lang)}.json` ) + .then(k => k.default) } const injectAnnotations = (emoji, annotations) => { @@ -233,21 +234,17 @@ const instance = { }, async getStaticEmoji ({ commit }) { try { - const res = await window.fetch('/static/emoji.json') - if (res.ok) { - const values = await res.json() - const emoji = Object.keys(values).reduce((res, groupId) => { - res[groupId] = values[groupId].map(e => ({ - displayText: e.slug, - imageUrl: false, - replacement: e.emoji - })) - return res - }, {}) - commit('setInstanceOption', { name: 'emoji', value: injectRegionalIndicators(emoji) }) - } else { - throw (res) - } + const values = (await import('../../static/emoji.json')).default + + const emoji = Object.keys(values).reduce((res, groupId) => { + res[groupId] = values[groupId].map(e => ({ + displayText: e.slug, + imageUrl: false, + replacement: e.emoji + })) + return res + }, {}) + commit('setInstanceOption', { name: 'emoji', value: injectRegionalIndicators(emoji) }) } catch (e) { console.warn("Can't load static emoji") console.warn(e) diff --git a/yarn.lock b/yarn.lock @@ -8138,11 +8138,6 @@ unicode-canonical-property-names-ecmascript@^2.0.0: resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc" integrity sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ== -unicode-emoji-json@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/unicode-emoji-json/-/unicode-emoji-json-0.3.0.tgz#965e097ef8a367081c5036f81873015a95a5c1ad" - integrity sha512-yImheILedqhZtVEEenRELu9AnX347ZTA3bVMWAU5WMUv7pdU2hcfpwo2mKN8Rns9uHLmOZP90/4B4SPS5aF/iw== - unicode-match-property-ecmascript@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz#54fd16e0ecb167cf04cf1f756bdcc92eba7976c3"