fix ui: fix notes pagination
This commit is contained in:
parent
8fe44d72f9
commit
b037c801db
5 changed files with 19 additions and 91 deletions
|
|
@ -44,11 +44,11 @@ function NotesList({ members }: { members: Array<Record<string, any>> }) {
|
|||
<div className="text-disabled-text">
|
||||
Showing{' '}
|
||||
<span className="font-semibold">{Math.min(list.length, notesStore.pageSize)}</span> out
|
||||
of <span className="font-semibold">{list.length}</span> notes
|
||||
of <span className="font-semibold">{notesStore.total}</span> notes
|
||||
</div>
|
||||
<Pagination
|
||||
page={notesStore.page}
|
||||
total={list.length}
|
||||
total={notesStore.total}
|
||||
onPageChange={(page) => notesStore.changePage(page)}
|
||||
limit={notesStore.pageSize}
|
||||
debounceRequest={100}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import { makeAutoObservable } from "mobx"
|
||||
import { notesService } from "App/services"
|
||||
import { Note, WriteNote, iTag, NotesFilter } from 'App/services/NotesService'
|
||||
import { makeAutoObservable } from "mobx";
|
||||
|
||||
|
||||
|
||||
import { notesService } from "App/services";
|
||||
import { Note, NotesFilter, WriteNote, iTag } from 'App/services/NotesService';
|
||||
|
||||
|
||||
export default class NotesStore {
|
||||
notes: Note[] = []
|
||||
|
|
@ -12,6 +16,7 @@ export default class NotesStore {
|
|||
sort = 'createdAt'
|
||||
order: 'DESC' | 'ASC' = 'DESC'
|
||||
ownOnly = false
|
||||
total = 0
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this)
|
||||
|
|
@ -20,9 +25,15 @@ export default class NotesStore {
|
|||
setLoading(loading: boolean) {
|
||||
this.loading = loading
|
||||
}
|
||||
|
||||
setNotes(notes: Note[]) {
|
||||
this.notes = notes
|
||||
}
|
||||
|
||||
setTotal(total: number) {
|
||||
this.total = total
|
||||
}
|
||||
|
||||
async fetchNotes() {
|
||||
const filter: NotesFilter = {
|
||||
page: this.page,
|
||||
|
|
@ -36,8 +47,9 @@ export default class NotesStore {
|
|||
|
||||
this.setLoading(true)
|
||||
try {
|
||||
const notes = await notesService.fetchNotes(filter)
|
||||
const { notes, count } = await notesService.fetchNotes(filter);
|
||||
this.setNotes(notes);
|
||||
this.setTotal(count)
|
||||
return notes;
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export default class NotesService {
|
|||
this.client = client || new APIClient();
|
||||
}
|
||||
|
||||
fetchNotes(filter: NotesFilter): Promise<Note[]> {
|
||||
fetchNotes(filter: NotesFilter): Promise<{ notes: Note[], count: number }> {
|
||||
return this.client.post('/notes', filter).then(r => {
|
||||
return r.json().then(r => r.data)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
if git diff --cached --name-only | grep -v '\.gen\.ts$' | grep --quiet '^tracker/tracker/'
|
||||
then
|
||||
echo "tracker"
|
||||
pwd
|
||||
cd tracker/tracker
|
||||
|
||||
bun run lint-front
|
||||
|
||||
cd ../../
|
||||
fi
|
||||
|
||||
if git diff --cached --name-only | grep -v '\.gen\.ts$' | grep --quiet '^tracker/tracker-assist/'
|
||||
then
|
||||
echo "tracker-assist"
|
||||
cd tracker/tracker-assist
|
||||
|
||||
bun run lint-front
|
||||
|
||||
cd ../../
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
if [ "$LEFTHOOK" = "0" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
call_lefthook()
|
||||
{
|
||||
if test -n "$LEFTHOOK_BIN"
|
||||
then
|
||||
"$LEFTHOOK_BIN" "$@"
|
||||
elif lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
lefthook "$@"
|
||||
else
|
||||
dir="$(git rev-parse --show-toplevel)"
|
||||
if test -f "$dir/node_modules/lefthook/bin/index.js"
|
||||
then
|
||||
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
||||
else
|
||||
osArch=$(uname | tr '[:upper:]' '[:lower:]')
|
||||
cpuArch=$(uname -m | sed 's/aarch64/arm64/')
|
||||
if test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
||||
then
|
||||
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
|
||||
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
||||
then
|
||||
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
|
||||
|
||||
elif bundle exec lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
bundle exec lefthook "$@"
|
||||
elif yarn lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
yarn lefthook "$@"
|
||||
elif pnpm lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
pnpm lefthook "$@"
|
||||
elif swift package plugin lefthook >/dev/null 2>&1
|
||||
then
|
||||
swift package --disable-sandbox plugin lefthook "$@"
|
||||
elif command -v mint >/dev/null 2>&1
|
||||
then
|
||||
mint run csjones/lefthook-plugin "$@"
|
||||
elif command -v npx >/dev/null 2>&1
|
||||
then
|
||||
npx lefthook "$@"
|
||||
else
|
||||
echo "Can't find lefthook in PATH"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
call_lefthook run "prepare-commit-msg" "$@"
|
||||
Loading…
Add table
Reference in a new issue