mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 21:26:40 +00:00
[bugfix/frontend] Fix 'steal this look' emoji promise mapping (#2270)
* [bugfix/frontend] Fix 'steal this look' emoji promise mapping * indent a bit nicer
This commit is contained in:
parent
637f188ebe
commit
0dfb26097d
|
@ -169,24 +169,33 @@ const extended = gtsApi.injectEndpoints({
|
||||||
|
|
||||||
// Search for each listed emoji with the admin
|
// Search for each listed emoji with the admin
|
||||||
// api to get the version that includes an ID.
|
// api to get the version that includes an ID.
|
||||||
const withIDs: CustomEmoji[] = [];
|
|
||||||
const errors: FetchBaseQueryError[] = [];
|
const errors: FetchBaseQueryError[] = [];
|
||||||
|
const withIDs: CustomEmoji[] = (
|
||||||
withoutIDs.forEach(async(emoji) => {
|
await Promise.all(
|
||||||
// Request admin view of this emoji.
|
withoutIDs.map(async(emoji) => {
|
||||||
const emojiRes = await fetchWithBQ({
|
// Request admin view of this emoji.
|
||||||
url: `/api/v1/admin/custom_emojis`,
|
const emojiRes = await fetchWithBQ({
|
||||||
params: {
|
url: `/api/v1/admin/custom_emojis`,
|
||||||
filter: `domain:${domain},shortcode:${emoji.shortcode}`,
|
params: {
|
||||||
limit: 1
|
filter: `domain:${domain},shortcode:${emoji.shortcode}`,
|
||||||
}
|
limit: 1
|
||||||
});
|
}
|
||||||
if (emojiRes.error) {
|
});
|
||||||
errors.push(emojiRes.error);
|
|
||||||
} else {
|
if (emojiRes.error) {
|
||||||
// Got it!
|
// Put error in separate array so
|
||||||
withIDs.push(emojiRes.data as CustomEmoji);
|
// 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) {
|
if (errors.length !== 0) {
|
||||||
|
|
Loading…
Reference in a new issue