Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
selectdev committed Jul 7, 2022
1 parent 54e5f5e commit 271549f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/routes/api/entries.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/routes/edit/[slug].svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
async function submitEntry() {
// make a put request to /api/entry/<id>.json
// if successful, redirect to /entry/<slug>
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: {
Expand Down
7 changes: 3 additions & 4 deletions src/routes/edit/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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/<slug>
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: {
Expand Down
6 changes: 4 additions & 2 deletions src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -70,6 +71,7 @@
$: {
;[showVisible, showUnlisted, showHidden]
if (browser) {
updateEntries()
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

Expand All @@ -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({
Expand Down

0 comments on commit 271549f

Please sign in to comment.