30bbbaf00b
* Make eslint sort our imports * fix missing deps in eslint rule (dae) Caught on Linux due to the stricter sandboxing * Remove exports-last eslint rule (for now?) * Adjust browserslist settings - We use ResizeObserver which is not supported in browsers like KaiOS, Baidu or Android UC * Raise minimum iOS version 13.4 - It's the first version that supports ResizeObserver * Apply new eslint rules to sort imports
27 lines
886 B
TypeScript
27 lines
886 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import * as tr from "../lib/ftl";
|
|
import type { Scheduler } from "../lib/proto";
|
|
import { naturalUnit, unitAmount, unitName } from "../lib/time";
|
|
|
|
export function buildNextLearnMsg(info: Scheduler.CongratsInfoResponse): string {
|
|
const secsUntil = info.secsUntilNextLearn;
|
|
// next learning card not due today?
|
|
if (secsUntil >= 86_400) {
|
|
return "";
|
|
}
|
|
|
|
const unit = naturalUnit(secsUntil);
|
|
const amount = Math.round(unitAmount(unit, secsUntil));
|
|
const unitStr = unitName(unit);
|
|
const nextLearnDue = tr.schedulingNextLearnDue({
|
|
amount,
|
|
unit: unitStr,
|
|
});
|
|
const remaining = tr.schedulingLearnRemaining({
|
|
remaining: info.learnRemaining,
|
|
});
|
|
return `${nextLearnDue} ${remaining}`;
|
|
}
|