Trash feature done
This commit is contained in:
@@ -29,11 +29,17 @@ class NoteService(
|
||||
.map { Note(it.metadata, markdown = markdownText, html = it.html) }
|
||||
.map { noteRepository.update(userId, uuid, it) }
|
||||
|
||||
fun paginatedNotes(userId: Int, page: Int, itemsPerPage: Int = 20, tag: String? = null): PaginatedNotes {
|
||||
val count = noteRepository.count(userId, tag)
|
||||
fun paginatedNotes(
|
||||
userId: Int,
|
||||
page: Int,
|
||||
itemsPerPage: Int = 20,
|
||||
tag: String? = null,
|
||||
deleted: Boolean = false
|
||||
): PaginatedNotes {
|
||||
val count = noteRepository.count(userId, tag, deleted)
|
||||
val offset = (page - 1) * itemsPerPage
|
||||
val numberOfPages = (count / itemsPerPage) + 1
|
||||
val notes = if (count == 0) emptyList() else noteRepository.findAll(userId, itemsPerPage, offset, tag)
|
||||
val notes = if (count == 0) emptyList() else noteRepository.findAll(userId, itemsPerPage, offset, tag, deleted)
|
||||
return PaginatedNotes(numberOfPages, notes)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user