mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 16:58:47 +01:00
Small optimization
This commit is contained in:
parent
4c188ab59b
commit
c316f0106b
1 changed files with 3 additions and 6 deletions
|
@ -42,6 +42,7 @@ import useTitle from '../utils/useTitle';
|
||||||
import getInstanceStatusURL from './../utils/get-instance-status-url';
|
import getInstanceStatusURL from './../utils/get-instance-status-url';
|
||||||
|
|
||||||
const LIMIT = 40;
|
const LIMIT = 40;
|
||||||
|
const MAX_WEIGHT = 5;
|
||||||
|
|
||||||
let cachedRepliesToggle = {};
|
let cachedRepliesToggle = {};
|
||||||
let cachedStatusesMap = {};
|
let cachedStatusesMap = {};
|
||||||
|
@ -595,11 +596,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const totalWeight = useMemo(() => {
|
const totalWeight = statuses?.length;
|
||||||
return statuses.reduce((acc, status) => {
|
|
||||||
return acc + status.weight;
|
|
||||||
}, 0);
|
|
||||||
}, [id, statuses?.length]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -1014,7 +1011,7 @@ function SubComments({ replies, instance, hasParentThread, level, accWeight }) {
|
||||||
.slice(0, 3);
|
.slice(0, 3);
|
||||||
|
|
||||||
let open = false;
|
let open = false;
|
||||||
if (accWeight < 5) {
|
if (accWeight <= MAX_WEIGHT) {
|
||||||
open = true;
|
open = true;
|
||||||
} else if (!hasParentThread && totalComments === 1) {
|
} else if (!hasParentThread && totalComments === 1) {
|
||||||
const shortReply = calcStatusWeight(replies[0]) < 2;
|
const shortReply = calcStatusWeight(replies[0]) < 2;
|
||||||
|
|
Loading…
Reference in a new issue