(props: NextRepTimeProps)
| 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 | |
| 35 | function numberWithLabel(number: number, label: string) { |
| 36 | return `${number} ${label}${number == 1 ? '' : 's'}`; |
| 37 | } |
| 38 | |
| 39 | export 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(); |
nothing calls this directly
no test coverage detected