Keep search query on reload

This commit is contained in:
2020-08-21 17:44:43 +02:00
parent 8ba89d3e05
commit c02f7c039a
3 changed files with 9 additions and 7 deletions
@@ -57,10 +57,11 @@ class NoteController(
}
fun search(request: Request, jwtPayload: JwtPayload): Response {
val terms = request.searchTerms()
val query = request.form("search") ?: ""
val terms = parseSearchTerms(query)
val notes = noteService.search(jwtPayload.userId, terms)
val deletedCount = noteService.countDeleted(jwtPayload.userId)
return Response(OK).html(view.search(jwtPayload, notes, deletedCount))
return Response(OK).html(view.search(jwtPayload, notes, query, deletedCount))
}
fun note(request: Request, jwtPayload: JwtPayload): Response {
@@ -132,6 +133,4 @@ class NoteController(
null
}
}
private fun Request.searchTerms(): SearchTerms = parseSearchTerms(form("search") ?: "")
}