Skip to content

Commit

Permalink
docs: Fix infinite loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Mar 5, 2022
1 parent 20f2f3e commit 35463d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions website/src/components/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export function processEmojis(

// This randomly is a set and i'm not sure why...
if (emoji.shortcodes instanceof Set) {
// eslint-disable-next-line no-console
console.debug('SET found', emoji.hexcode, emoji);

emoji.shortcodes = [...emoji.shortcodes].map(String);
}

Expand Down
10 changes: 8 additions & 2 deletions website/src/components/Shortcodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ export default function Shortcodes({ preset, shortcodes }: ShortcodesProps) {
// There's a weird bug where shortcdes in production are rendered as `:[object Set]:`,
// but it works completely fine locally. Even after a ton of debugging, I cannot
// figure it out, so I'm adding this function to just check a bunch of scenarios.
const handleValue = (value: ShortcodesProps['shortcodes']) => {
const handleValue = (value: ShortcodesProps['shortcodes'], depth: number = 0) => {
if (depth > 1) {
return;
}

if (typeof value === 'string') {
list.push(value);
} else if (value instanceof Set || Array.isArray(value)) {
[...value].forEach(handleValue);
[...value].forEach((v) => {
handleValue(v, depth + 1);
});
}
};

Expand Down

0 comments on commit 35463d6

Please sign in to comment.