mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 02:35:39 +03:00
More adjustment to auto-collapsing logic
This commit is contained in:
parent
d264af14f1
commit
4d5c0f1f5d
1 changed files with 9 additions and 11 deletions
|
@ -596,8 +596,6 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
|
|||
});
|
||||
}, []);
|
||||
|
||||
const totalWeight = statuses?.length;
|
||||
|
||||
return (
|
||||
<div
|
||||
tabIndex="-1"
|
||||
|
@ -911,7 +909,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
|
|||
replies={replies}
|
||||
hasParentThread={thread}
|
||||
level={1}
|
||||
accWeight={totalWeight}
|
||||
accWeight={weight}
|
||||
/>
|
||||
)}
|
||||
{uiState === 'loading' &&
|
||||
|
@ -1010,8 +1008,14 @@ function SubComments({ replies, instance, hasParentThread, level, accWeight }) {
|
|||
.filter((a, i, arr) => arr.findIndex((b) => b.id === a.id) === i)
|
||||
.slice(0, 3);
|
||||
|
||||
const totalWeight = useMemo(() => {
|
||||
return replies?.reduce((acc, reply) => {
|
||||
return acc + reply?.weight;
|
||||
}, accWeight);
|
||||
}, [accWeight, replies?.length]);
|
||||
|
||||
let open = false;
|
||||
if (accWeight <= MAX_WEIGHT) {
|
||||
if (totalWeight <= MAX_WEIGHT) {
|
||||
open = true;
|
||||
} else if (!hasParentThread && totalComments === 1) {
|
||||
const shortReply = calcStatusWeight(replies[0]) < 2;
|
||||
|
@ -1041,12 +1045,6 @@ function SubComments({ replies, instance, hasParentThread, level, accWeight }) {
|
|||
};
|
||||
}, []);
|
||||
|
||||
const totalWeight = useMemo(() => {
|
||||
return replies?.reduce((acc, reply) => {
|
||||
return acc + reply?.weight;
|
||||
}, 0);
|
||||
}, [replies?.length]);
|
||||
|
||||
return (
|
||||
<details
|
||||
ref={detailsRef}
|
||||
|
@ -1123,7 +1121,7 @@ function SubComments({ replies, instance, hasParentThread, level, accWeight }) {
|
|||
instance={instance}
|
||||
replies={r.replies}
|
||||
level={level + 1}
|
||||
accWeight={!open ? totalWeight : accWeight + totalWeight}
|
||||
accWeight={!open ? r.weight : totalWeight}
|
||||
/>
|
||||
)}
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue