We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17cbeb2 commit 556e343Copy full SHA for 556e343
src/renderer/components/SnippetResults/SnippetResults.tsx
@@ -13,9 +13,15 @@ export default function SnippetResults({ results }: SnippetResultsProps) {
13
const query = useUrlQuery();
14
const currentSnippetId = query.get('currentSnippetId');
15
16
- const currentSnippet = currentSnippetId
+ // if we have a snippet id in the url, search for that first
17
+ let currentSnippet = currentSnippetId
18
? results.find((recipe) => String(recipe.id) === currentSnippetId)
- : results[0] || {};
19
+ : undefined;
20
+
21
+ // if we can't find the snippet from the url or it wasn't given, use the first result
22
+ if (!currentSnippet) {
23
+ currentSnippet = results[0] || {};
24
+ }
25
26
return (
27
<Flex h="full" overflow="hidden">
0 commit comments