Skip to content

Commit

Permalink
Merge pull request #27 from ecency/bugfix/submit-word-count
Browse files Browse the repository at this point in the history
bugfix/submit-word-count
  • Loading branch information
feruzm authored Sep 23, 2024
2 parents e53a13d + a95ac44 commit e65c2ad
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/app/submit/_components/word-counter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,17 @@ export function WordCount({ selector, watch }: Props) {
setCount(words);
}, [selector]);

useEffect(() => {
countTime();
}, [countTime]);

useInterval(() => countTime, watch ? 1000 : null);

if (count > 0) {
return (
<div className="words-count">
<span className="words">{i18next.t("word-count.label", { n: count })}</span>
<span className="time">
{" "}
{time <= 0.8
? i18next.t("word-count.read-time-less-1-min")
: i18next.t("word-count.read-time-n-min", { n: Math.ceil(time) })}{" "}
</span>
</div>
);
}
return <></>;
useInterval(() => countTime(), watch ? 1000 : null);

return (
<div className="words-count">
<span className="words">{i18next.t("word-count.label", { n: count })}</span>
<span className="time">
{" "}
{time <= 0.8
? i18next.t("word-count.read-time-less-1-min")
: i18next.t("word-count.read-time-n-min", { n: Math.ceil(time) })}{" "}
</span>
</div>
);
}

0 comments on commit e65c2ad

Please sign in to comment.