Skip to content

Commit

Permalink
Merge pull request #654 from kitspace/ke/search-url-delay
Browse files Browse the repository at this point in the history
Delay search url updating to not add lots of half written queries
  • Loading branch information
kasbah authored Sep 23, 2024
2 parents 31a2e9c + d7895da commit 2b5d925
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions e2e/cypress/e2e/multiProject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ describe('Multi project page', () => {
// Search for the project
cy.get('[data-cy=search-field] > input').type(user.username)

cy.wait(1000)

// Click on a multiproject project card
cy.get('[data-cy=project-card]')
.first()
Expand Down
20 changes: 18 additions & 2 deletions frontend/src/components/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,29 @@ const SearchInput = () => {
}, [routerQuery])

const debouncedSubmit = useRef(debounce(value => updateContextQuery(value), 100))
const debouncedUpdateUrl = useRef(
debounce(value => {
const path = value ? `/search?q=${encodeURIComponent(value)}` : '/'
replace(path, undefined, { shallow: true })
}, 500),
)

// Cancel on component dismount
useEffect(() => {
return () => {
// I don't understand what react / eslint wants us to do in this case:
// the ref doesn't actually change.
// eslint-disable-next-line react-hooks/exhaustive-deps
debouncedUpdateUrl.current.cancel()
}
}, [])

const handleChange = (value: string) => {
debouncedSubmit.current.cancel()
debouncedUpdateUrl.current.cancel()
setInputQuery(value)
debouncedSubmit.current(value)
const path = value ? `/search?q=${encodeURIComponent(value)}` : '/'
replace(path, undefined, { shallow: true })
debouncedUpdateUrl.current(value)
}

return (
Expand Down
2 changes: 2 additions & 0 deletions processor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ RUN addgroup --gid 1000 node && \
mkdir /data /gitea-data && \
chown -R node /data /gitea-data

RUN git config --global --add safe.directory '*'

USER node
CMD ["node", "dist/src/main.js"]
1 change: 1 addition & 0 deletions processor/src/queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ async function sync(gitDir, checkoutDir) {
try {
await sh`git clone ${gitDir} ${checkoutDir}`
} catch (err) {
log.error(err)
if (err.stderr) {
return
}
Expand Down
6 changes: 4 additions & 2 deletions scripts/importBoardsTxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ async function generateGiteaAdminToken() {
)

if (!giteaAdminCommand.status.success) {
throw new Error('Failed to create gitea admin user')
console.error(giteaAdminCommand.output)
throw new Error("Failed to create gitea admin user")
}

const giteaAdminTokenCommand = await exec(
Expand All @@ -308,7 +309,8 @@ async function generateGiteaAdminToken() {
)

if (!giteaAdminTokenCommand.status.success) {
throw new Error('Failed to create gitea admin token')
console.error(giteaAdminTokenCommand.output)
throw new Error("Failed to create gitea admin token")
}

return giteaAdminTokenCommand.output.split('\n').at(-1)
Expand Down

0 comments on commit 2b5d925

Please sign in to comment.