Handle temporary Commentron bugs

Can be removed when bugs are fixed, but would still work if left there.
This commit is contained in:
infinite-persistence 2021-07-09 15:05:53 +08:00
parent 5ef95846d8
commit f8bdd0704f
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
3 changed files with 9 additions and 3 deletions

View file

@ -108,6 +108,7 @@ declare type CommentByIdParams = {
} }
declare type CommentByIdResponse = { declare type CommentByIdResponse = {
item: Comment,
items: Comment, items: Comment,
ancestors: Array<Comment>, ancestors: Array<Comment>,
} }

View file

@ -109,12 +109,12 @@ export function doCommentById(commentId: string) {
return (dispatch: Dispatch, getState: GetState) => { return (dispatch: Dispatch, getState: GetState) => {
return Comments.comment_by_id({ comment_id: commentId, with_ancestors: true }) return Comments.comment_by_id({ comment_id: commentId, with_ancestors: true })
.then((result: CommentByIdResponse) => { .then((result: CommentByIdResponse) => {
const { items, ancestors } = result; const { item, items, ancestors } = result;
dispatch({ dispatch({
type: ACTIONS.COMMENT_BY_ID_COMPLETED, type: ACTIONS.COMMENT_BY_ID_COMPLETED,
data: { data: {
comment: items, comment: item || items, // Requested a change to rename it to 'item'. This covers both.
ancestors: ancestors, ancestors: ancestors,
}, },
}); });

View file

@ -287,10 +287,15 @@ export default handleActions(
// in reality this doesn't matter and we can just // in reality this doesn't matter and we can just
// sort comments by their timestamp // sort comments by their timestamp
const commentIds = Array(comments.length); const commentIds = Array(comments.length);
totalCommentsById[claimId] = totalItems;
// totalCommentsById[claimId] = totalItems;
// --> currently, this value is only correct when done via a top-level query.
// Until this is fixed, I'm moving it downwards to **
// --- Top-level comments --- // --- Top-level comments ---
if (!parentId) { if (!parentId) {
totalCommentsById[claimId] = totalItems; // **
topLevelTotalCommentsById[claimId] = totalFilteredItems; topLevelTotalCommentsById[claimId] = totalFilteredItems;
topLevelTotalPagesById[claimId] = totalPages; topLevelTotalPagesById[claimId] = totalPages;