From dcd088fc34894bb5236459fffee2ea782c3699b6 Mon Sep 17 00:00:00 2001 From: Jon Dough <49297268+jetstream0@users.noreply.github.com> Date: Sun, 19 Jun 2022 22:41:08 +0000 Subject: [PATCH] mat review compliance thing --- src/lib/EntryPreview.svelte | 4 ++-- src/routes/index.svelte | 42 ++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/lib/EntryPreview.svelte b/src/lib/EntryPreview.svelte index 65fe3545..64d0c333 100644 --- a/src/lib/EntryPreview.svelte +++ b/src/lib/EntryPreview.svelte @@ -35,7 +35,7 @@ {#if entry.tags} {#each entry.tags as tag} -

{ setTagSearch({ tag }) @@ -43,7 +43,7 @@ }} > {tag} -

+ {/each} {/if} diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 76df5e72..57fbfd60 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -31,22 +31,22 @@ let showVisible = true let showUnlisted = false let showHidden = false + let searchValue = '' let fetchIndex = 0 async function updateEntries() { fetchIndex += 1 let thisFetchIndex = fetchIndex - let search_value = (document.getElementById('search') as HTMLInputElement).value || null let tags: string let query: string - if (!search_value) { + if (!searchValue) { query = undefined } else { - let all = search_value.split(' ') + let all = searchValue.split(' ') query = all.filter(word => !word.startsWith('tags:')).join(' ') - if (search_value.includes('tags:')) { + if (searchValue.includes('tags:')) { let tags_raw = all.filter(word => word.startsWith('tags:'))[0] tags = tags_raw.slice(5).replaceAll('_', '%20') console.log(query) @@ -65,20 +65,7 @@ const res = await fetch(url) const newEntries = await res.json() - if (newEntries.length === 0) { - entries = [ - { - title: 'No Results Found', - content: 'Sorry, there are no results found with that query!', - slug: 'entry_does_not_exist', - id: '0', - tags: ['Error'], - visibility: 'visible', - }, - ] - } else { - if (thisFetchIndex === fetchIndex) entries = newEntries - } + if (thisFetchIndex === fetchIndex) entries = newEntries } $: { @@ -121,13 +108,24 @@ {/if}
- +
- {#each entries as entry} - - {/each} + {#if entries.length !== 0} + {#each entries as entry} + + {/each} + {:else} +

No entries with query found

+ {/if}