Use new param to remove sort-pins-first.

comment.List currently always pushes pins to the top to support pagination. This new param removes this behavior.
This commit is contained in:
infinite-persistence 2021-10-01 08:36:45 +08:00
parent 37327185b1
commit 76b16d676e
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
5 changed files with 7 additions and 6 deletions

View file

@ -118,7 +118,7 @@ declare type CommentListParams = {
parent_id?: string, // filters comments to those under this thread parent_id?: string, // filters comments to those under this thread
top_level?: boolean, // filters to only top level comments top_level?: boolean, // filters to only top level comments
hidden?: boolean, // if true, will show hidden comments as well hidden?: boolean, // if true, will show hidden comments as well
sort_by?: number, // NEWEST=0, OLDEST=1, CONTROVERSY=2, POPULARITY=3, sort_by?: number, // @see: ui/constants/comments.js::SORT_BY
}; };
declare type CommentListResponse = { declare type CommentListResponse = {

View file

@ -9,6 +9,7 @@ export const SORT_BY = {
OLDEST: 1, OLDEST: 1,
CONTROVERSY: 2, CONTROVERSY: 2,
POPULARITY: 3, POPULARITY: 3,
NEWEST_NO_PINS: 4,
}; };
export const BLOCK_LEVEL = { export const BLOCK_LEVEL = {

View file

@ -27,7 +27,7 @@ const select = (state) => {
const perform = (dispatch) => ({ const perform = (dispatch) => ({
doCommentReset: (a) => dispatch(doCommentReset(a)), doCommentReset: (a) => dispatch(doCommentReset(a)),
doCommentListOwn: (a, b, c, d) => dispatch(doCommentListOwn(a, b, c, d)), doCommentListOwn: (a, b, c) => dispatch(doCommentListOwn(a, b, c)),
}); });
export default connect(select, perform)(OwnComments); export default connect(select, perform)(OwnComments);

View file

@ -8,7 +8,7 @@ import Card from 'component/common/card';
import Empty from 'component/common/empty'; import Empty from 'component/common/empty';
import Page from 'component/page'; import Page from 'component/page';
import Spinner from 'component/spinner'; import Spinner from 'component/spinner';
import { SORT_BY, COMMENT_PAGE_SIZE_TOP_LEVEL } from 'constants/comment'; import { COMMENT_PAGE_SIZE_TOP_LEVEL } from 'constants/comment';
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
import useFetched from 'effects/use-fetched'; import useFetched from 'effects/use-fetched';
import debounce from 'util/debounce'; import debounce from 'util/debounce';
@ -29,7 +29,7 @@ type Props = {
isFetchingComments: boolean, isFetchingComments: boolean,
claimsById: any, claimsById: any,
doCommentReset: (claimId: string) => void, doCommentReset: (claimId: string) => void,
doCommentListOwn: (channelId: string, page: number, pageSize: number, sortBy: number) => void, doCommentListOwn: (channelId: string, page: number, pageSize: number) => void,
}; };
export default function OwnComments(props: Props) { export default function OwnComments(props: Props) {
@ -117,7 +117,7 @@ export default function OwnComments(props: Props) {
// Fetch own comments // Fetch own comments
React.useEffect(() => { React.useEffect(() => {
if (page !== 0 && activeChannelId) { if (page !== 0 && activeChannelId) {
doCommentListOwn(activeChannelId, page, COMMENT_PAGE_SIZE_TOP_LEVEL, SORT_BY.NEWEST); doCommentListOwn(activeChannelId, page, COMMENT_PAGE_SIZE_TOP_LEVEL);
} }
}, [page]); // eslint-disable-line react-hooks/exhaustive-deps }, [page]); // eslint-disable-line react-hooks/exhaustive-deps

View file

@ -212,7 +212,7 @@ export function doCommentListOwn(
channelId: string, channelId: string,
page: number = 1, page: number = 1,
pageSize: number = 99999, pageSize: number = 99999,
sortBy: number = SORT_BY.NEWEST sortBy: number = SORT_BY.NEWEST_NO_PINS
) { ) {
return async (dispatch: Dispatch, getState: GetState) => { return async (dispatch: Dispatch, getState: GetState) => {
const state = getState(); const state = getState();