mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:21:35 +00:00
refactor(auth): share remaining-time formatter
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { formatRemainingShort } from "../../agents/auth-health.js";
|
||||
import {
|
||||
isProfileInCooldown,
|
||||
resolveAuthProfileDisplayLabel,
|
||||
@@ -32,23 +33,8 @@ export const resolveAuthLabel = async (
|
||||
const lastGood = findNormalizedProviderValue(store.lastGood, providerKey);
|
||||
const nextProfileId = order[0];
|
||||
const now = Date.now();
|
||||
|
||||
const formatUntil = (timestampMs: number) => {
|
||||
const remainingMs = Math.max(0, timestampMs - now);
|
||||
const minutes = Math.round(remainingMs / 60_000);
|
||||
if (minutes < 1) {
|
||||
return "soon";
|
||||
}
|
||||
if (minutes < 60) {
|
||||
return `${minutes}m`;
|
||||
}
|
||||
const hours = Math.round(minutes / 60);
|
||||
if (hours < 48) {
|
||||
return `${hours}h`;
|
||||
}
|
||||
const days = Math.round(hours / 24);
|
||||
return `${days}d`;
|
||||
};
|
||||
const formatUntil = (timestampMs: number) =>
|
||||
formatRemainingShort(timestampMs - now, { underMinuteLabel: "soon" });
|
||||
|
||||
if (order.length > 0) {
|
||||
if (mode === "compact") {
|
||||
|
||||
Reference in New Issue
Block a user