MCPcopy Create free account
hub / github.com/bjsi/incremental-everything / NextRepTime

Function NextRepTime

src/components/NextRepTime.tsx:31–50  ·  view source on GitHub ↗
(props: NextRepTimeProps)

Source from the content-addressed store, hash-verified

29 ? numberWithLabel(Math.round(duration.asDays()), 'day')
30 : duration.asMonths() < 12
31 ? numberWithLabel(Math.round(duration.asMonths() * 10) / 10, 'month')
32 : numberWithLabel(Math.round(duration.asYears() * 10) / 10, 'year');
33}
34
35function numberWithLabel(number: number, label: string) {
36 return `${number} ${label}${number == 1 ? '' : 's'}`;
37}
38
39export function NextRepTime(props: NextRepTimeProps): React.ReactElement {
40 const [nextTime, setNextTime] = React.useState<number>();
41 const [scheduler, setScheduler] = React.useState<ResolvedScheduler>();
42 const plugin = usePlugin();
43
44 React.useEffect(() => {
45 const effect = async () => {
46 const inLookbackMode = !!(await plugin.queue.inLookbackMode());
47 const nt = await getNextSpacingDateForRem(plugin, props.rem.remId, inLookbackMode);
48 if (nt) {
49 setNextTime(nt.newNextRepDate);
50 setScheduler(nt.scheduler);
51 }
52 };
53 effect();

Callers

nothing calls this directly

Calls 2

effectFunction · 0.85
durationToHumanReadableFunction · 0.85

Tested by

no test coverage detected