remove useless try/catch
This commit is contained in:
parent
efb091fead
commit
b3d5542a10
1 changed files with 35 additions and 39 deletions
|
@ -9,45 +9,41 @@ const denoCore: DenoCore = Deno[Deno.internal].core;
|
|||
export default function EmojiPicker(props: { text: string }): ReactNode | undefined {
|
||||
const text = props.text;
|
||||
|
||||
try {
|
||||
if (text.length < 3) {
|
||||
return undefined
|
||||
};
|
||||
|
||||
const emoji = UnicodeEmoji.getEmojis().find(emoji => emoji.keywords.includes(text));
|
||||
if (!emoji) {
|
||||
return undefined
|
||||
};
|
||||
|
||||
return (
|
||||
<Inline
|
||||
actions={
|
||||
<ActionPanel>
|
||||
<Action
|
||||
label={`Copy ${emoji.emoji} to clipboard`}
|
||||
onAction={async () => {
|
||||
console.log(emoji.emoji)
|
||||
await Clipboard.writeText(emoji.emoji);
|
||||
showHud(`${emoji.emoji} copied to clipboard`);
|
||||
}}
|
||||
/>
|
||||
</ActionPanel>
|
||||
}
|
||||
>
|
||||
<Inline.Left>
|
||||
<Content.H3>
|
||||
{text}
|
||||
</Content.H3>
|
||||
</Inline.Left>
|
||||
<Inline.Separator icon={Icons.ArrowRight}/>
|
||||
<Inline.Right>
|
||||
<Content.H3>
|
||||
{emoji.emoji}
|
||||
</Content.H3>
|
||||
</Inline.Right>
|
||||
</Inline>
|
||||
)
|
||||
} catch (e) {
|
||||
if (text.length < 3) {
|
||||
return undefined
|
||||
};
|
||||
|
||||
const emoji = UnicodeEmoji.getEmojis().find(emoji => emoji.keywords.includes(text));
|
||||
if (!emoji) {
|
||||
return undefined
|
||||
};
|
||||
|
||||
return (
|
||||
<Inline
|
||||
actions={
|
||||
<ActionPanel>
|
||||
<Action
|
||||
label={`Copy ${emoji.emoji} to clipboard`}
|
||||
onAction={async () => {
|
||||
console.log(emoji.emoji)
|
||||
await Clipboard.writeText(emoji.emoji);
|
||||
showHud(`${emoji.emoji} copied to clipboard`);
|
||||
}}
|
||||
/>
|
||||
</ActionPanel>
|
||||
}
|
||||
>
|
||||
<Inline.Left>
|
||||
<Content.H3>
|
||||
{text}
|
||||
</Content.H3>
|
||||
</Inline.Left>
|
||||
<Inline.Separator icon={Icons.ArrowRight}/>
|
||||
<Inline.Right>
|
||||
<Content.H3>
|
||||
{emoji.emoji}
|
||||
</Content.H3>
|
||||
</Inline.Right>
|
||||
</Inline>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue