diff --git a/src/routes/api/entries.json.ts b/src/routes/api/entries.json.ts index 7f9d96e6..952b318b 100644 --- a/src/routes/api/entries.json.ts +++ b/src/routes/api/entries.json.ts @@ -10,7 +10,11 @@ export const get: RequestHandler = async req => { const showVisible = req.url.searchParams.get('visible') !== 'false' const showUnlisted = req.url.searchParams.get('unlisted') === 'true' const showHidden = req.url.searchParams.get('hidden') === 'true' - const tags = req.url.searchParams.get('tags')?.split(',')?.map(tag => tag.trim())?.filter(tag => tag.length > 0) + const tags = req.url.searchParams + .get('tags') + ?.split(',') + ?.map(tag => tag.trim()) + ?.filter(tag => tag.length > 0) const query = req.url.searchParams.get('query') const user = req.locals.user ? await fetchUser({ id: req.locals.user.id }) : null diff --git a/src/routes/edit/[slug].svelte b/src/routes/edit/[slug].svelte index 0420b804..0e044953 100644 --- a/src/routes/edit/[slug].svelte +++ b/src/routes/edit/[slug].svelte @@ -47,7 +47,10 @@ async function submitEntry() { // make a put request to /api/entry/.json // if successful, redirect to /entry/ - entryTags = entryTags.split(',').map(tag => tag.trim()).filter(tag => tag.length > 0) + entryTags = entryTags + .split(',') + .map(tag => tag.trim()) + .filter(tag => tag.length > 0) const response: Entry | { error: string } = await fetch(`/api/entry/${entry.id}.json`, { method: 'PUT', headers: { diff --git a/src/routes/edit/index.svelte b/src/routes/edit/index.svelte index 5c9a8e8d..d264884e 100644 --- a/src/routes/edit/index.svelte +++ b/src/routes/edit/index.svelte @@ -42,13 +42,12 @@ pageTitle = entryTitle.length ? `New entry "${entryTitle}"` : 'New entry' } - async function submitEntry() { + const submitEntry = async () => { // make a post/put request to /api/entries.json // if successful, redirect to /entry/ entryTags = entryTags.split(',') - if (entryTags.length == 1 && entryTags[0] == '') { - entryTags = [] - } + if (entryTags.length == 1 && entryTags[0] == '') entryTags = [] + const response: Entry | { error: string } = await fetch('/api/entries.json', { method: 'POST', headers: { diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 57fbfd60..bc939b40 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -35,21 +35,22 @@ let fetchIndex = 0 - async function updateEntries() { + const updateEntries = async () => { fetchIndex += 1 let thisFetchIndex = fetchIndex let tags: string let query: string + if (!searchValue) { query = undefined } else { let all = searchValue.split(' ') query = all.filter(word => !word.startsWith('tags:')).join(' ') + if (searchValue.includes('tags:')) { let tags_raw = all.filter(word => word.startsWith('tags:'))[0] tags = tags_raw.slice(5).replaceAll('_', '%20') - console.log(query) } } @@ -70,6 +71,7 @@ $: { ;[showVisible, showUnlisted, showHidden] + if (browser) { updateEntries() } diff --git a/src/routes/login.ts b/src/routes/login.ts index 75bf2c42..79bf4959 100644 --- a/src/routes/login.ts +++ b/src/routes/login.ts @@ -52,7 +52,6 @@ export const get: RequestHandler = async req => { }).then(res => res.json()) if (!discordUserData.id) { - console.log(discordUserData) throw new Error('Failed to get user data from Discord') } @@ -64,6 +63,7 @@ export const get: RequestHandler = async req => { }) let sessionId: string + if (existingRepldexUser) { // the user has a repldex account, create a new session for them sessionId = await createSession({