diff options
author | 2023-10-17 18:59:23 +0200 | |
---|---|---|
committer | 2023-10-17 18:59:23 +0200 | |
commit | 0dfb26097d11e8d3a10d098c182ce5f7abfe3fe9 (patch) | |
tree | 9f4dc700d701a21b07aecb9e9c6bd31b790a4b53 /web/source/settings/lib/query/admin/custom-emoji/index.ts | |
parent | [feature] Allow import/export/creation of domain allows via admin panel (#2264) (diff) | |
download | gotosocial-0dfb26097d11e8d3a10d098c182ce5f7abfe3fe9.tar.xz |
[bugfix/frontend] Fix 'steal this look' emoji promise mapping (#2270)
* [bugfix/frontend] Fix 'steal this look' emoji promise mapping
* indent a bit nicer
Diffstat (limited to 'web/source/settings/lib/query/admin/custom-emoji/index.ts')
-rw-r--r-- | web/source/settings/lib/query/admin/custom-emoji/index.ts | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/web/source/settings/lib/query/admin/custom-emoji/index.ts b/web/source/settings/lib/query/admin/custom-emoji/index.ts index d624b0580..204fb1c1f 100644 --- a/web/source/settings/lib/query/admin/custom-emoji/index.ts +++ b/web/source/settings/lib/query/admin/custom-emoji/index.ts @@ -169,24 +169,33 @@ const extended = gtsApi.injectEndpoints({ // Search for each listed emoji with the admin // api to get the version that includes an ID. - const withIDs: CustomEmoji[] = []; const errors: FetchBaseQueryError[] = []; - - withoutIDs.forEach(async(emoji) => { - // Request admin view of this emoji. - const emojiRes = await fetchWithBQ({ - url: `/api/v1/admin/custom_emojis`, - params: { - filter: `domain:${domain},shortcode:${emoji.shortcode}`, - limit: 1 - } - }); - if (emojiRes.error) { - errors.push(emojiRes.error); - } else { - // Got it! - withIDs.push(emojiRes.data as CustomEmoji); - } + const withIDs: CustomEmoji[] = ( + await Promise.all( + withoutIDs.map(async(emoji) => { + // Request admin view of this emoji. + const emojiRes = await fetchWithBQ({ + url: `/api/v1/admin/custom_emojis`, + params: { + filter: `domain:${domain},shortcode:${emoji.shortcode}`, + limit: 1 + } + }); + + if (emojiRes.error) { + // Put error in separate array so + // the null can be filtered nicely. + errors.push(emojiRes.error); + return null; + } + + // Got it! + return emojiRes.data as CustomEmoji; + }) + ) + ).flatMap((emoji) => { + // Remove any nulls. + return emoji || []; }); if (errors.length !== 0) { |