-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding cursor pagination. Fixes #2155 #2173
Changes from 2 commits
22f3996
afb2a2a
fc41123
9f9a2b6
a275587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, linkEvent } from "inferno"; | ||
import { I18NextService } from "../../services"; | ||
import { PaginationCursor } from "lemmy-js-client"; | ||
|
||
interface PaginatorCursorProps { | ||
prevPage?: PaginationCursor; | ||
nextPage?: PaginationCursor; | ||
onNext(val: PaginationCursor): any; | ||
onPrev(): any; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use what gets returned from this (if anything), so it could just return |
||
} | ||
|
||
export class PaginatorCursor extends Component<PaginatorCursorProps, any> { | ||
constructor(props: any, context: any) { | ||
super(props, context); | ||
} | ||
render() { | ||
return ( | ||
<div className="paginator my-2"> | ||
<button | ||
className="btn btn-secondary me-2" | ||
disabled={!this.props.prevPage} | ||
onClick={linkEvent(this, this.handlePrev)} | ||
> | ||
{I18NextService.i18n.t("prev")} | ||
</button> | ||
<button | ||
className="btn btn-secondary" | ||
onClick={linkEvent(this, this.handleNext)} | ||
disabled={!this.props.nextPage} | ||
> | ||
{I18NextService.i18n.t("next")} | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
handlePrev(i: PaginatorCursor) { | ||
i.props.onPrev(); | ||
} | ||
|
||
handleNext(i: PaginatorCursor) { | ||
if (i.props.nextPage) { | ||
i.props.onNext(i.props.nextPage); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: these can be declared as regular functions instead of class methods since you are using |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use the return value for this? If not, we could make this return
void
as well.