feat(accounts): show current account check status
This commit is contained in:
+4
-15
@@ -989,19 +989,7 @@ function formatDebridLinkCountQuota(info: DebridLinkHostLimitInfo | null | undef
|
||||
return info.note || "Nicht verfügbar";
|
||||
}
|
||||
|
||||
function formatCheckedAgo(checkedAt: number): string {
|
||||
const deltaMs = Date.now() - checkedAt;
|
||||
if (!Number.isFinite(deltaMs) || deltaMs < 0) return "gerade eben";
|
||||
const min = Math.floor(deltaMs / 60000);
|
||||
if (min < 1) return "gerade eben";
|
||||
if (min < 60) return `vor ${min} Min`;
|
||||
const hours = Math.floor(min / 60);
|
||||
if (hours < 24) return `vor ${hours} Std`;
|
||||
const days = Math.floor(hours / 24);
|
||||
return `vor ${days} Tag${days === 1 ? "" : "en"}`;
|
||||
}
|
||||
|
||||
function rotationEventText(ev: { event: string; cooldownSec?: number; next?: string; reason?: string }): string {
|
||||
function rotationEventText(ev: { event: string; cooldownSec?: number; next?: string; reason?: string }): string {
|
||||
const untilRestart = /bis zum Tagesreset gesperrt/i.test(ev.reason || "");
|
||||
switch (ev.event) {
|
||||
case "OK": return "erfolgreich";
|
||||
@@ -5058,7 +5046,7 @@ export function App(): ReactElement {
|
||||
: null;
|
||||
const accountSources = useMemo<AccountRowSource[]>(() => accountRows.map((row) => {
|
||||
const checkedStatus = row.accountId ? snapshot.settings.debridAccountStatuses?.[row.accountId] : undefined;
|
||||
const state: AccountRowSource["status"]["state"] = resolveAccountStatusState(row.disabled, checkedStatus);
|
||||
const state: AccountRowSource["status"]["state"] = resolveAccountStatusState(row.disabled, checkedStatus, runtimeNow);
|
||||
return {
|
||||
identityId: row.accountId || row.rowKey,
|
||||
service: row.entry.service,
|
||||
@@ -5070,6 +5058,7 @@ export function App(): ReactElement {
|
||||
state,
|
||||
message: checkedStatus?.message || row.entry.statusLabel,
|
||||
premiumUntilMs: checkedStatus?.premiumUntilMs ?? null,
|
||||
checkedAt: checkedStatus?.checkedAt,
|
||||
username: checkedStatus?.username,
|
||||
email: checkedStatus?.email
|
||||
},
|
||||
@@ -5079,7 +5068,7 @@ export function App(): ReactElement {
|
||||
credentialKind: row.credentialLabel.includes("API") ? "api-key" : row.credentialLabel.includes("•") ? "password" : "protected",
|
||||
canCheck: row.checkable
|
||||
};
|
||||
}), [accountRows, snapshot.settings.debridAccountStatuses]);
|
||||
}), [accountRows, runtimeNow, snapshot.settings.debridAccountStatuses]);
|
||||
const selectedAccountViewIds = useMemo(() => accountRows
|
||||
.filter((row) => selectedAccountRowKeys.has(row.rowKey))
|
||||
.map(accountRowViewId), [accountRows, selectedAccountRowKeys]);
|
||||
|
||||
@@ -117,7 +117,8 @@ export function resolveAccountUsername(storedUsername: string, checkedEmail?: st
|
||||
|
||||
export function resolveAccountStatusState(
|
||||
disabled: boolean,
|
||||
checkedStatus?: { valid: boolean; isPremium: boolean }
|
||||
checkedStatus?: { valid: boolean; isPremium: boolean; premiumUntilMs?: number | null },
|
||||
nowMs: number = Date.now()
|
||||
): "disabled" | "unchecked" | "invalid" | "free" | "premium" {
|
||||
if (checkedStatus && !checkedStatus.valid) {
|
||||
return "invalid";
|
||||
@@ -128,6 +129,13 @@ export function resolveAccountStatusState(
|
||||
if (!checkedStatus) {
|
||||
return "unchecked";
|
||||
}
|
||||
if (checkedStatus.isPremium
|
||||
&& typeof checkedStatus.premiumUntilMs === "number"
|
||||
&& Number.isFinite(checkedStatus.premiumUntilMs)
|
||||
&& checkedStatus.premiumUntilMs > 0
|
||||
&& checkedStatus.premiumUntilMs <= nowMs) {
|
||||
return "free";
|
||||
}
|
||||
return checkedStatus.isPremium ? "premium" : "free";
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ const pairs = [
|
||||
["Liste leeren", "Clear list"], ["Sitzung", "Session"], ["Gesamt", "Total"], ["Verbleibend", "Remaining"], ["Bereit", "Ready"], ["Download läuft", "Download running"], ["Wartet", "Waiting"], ["Offline", "Offline"],
|
||||
["Übersicht", "Overview"], ["Verwendungsregeln", "Usage rules"], ["Laufzeit", "Runtime"], ["Accountverwaltung", "Account management"], ["Accounts hinzufügen, prüfen und verwalten.", "Add, check and manage accounts."],
|
||||
["Provider-Laufzeit", "Provider runtime"], ["Account-Laufzeit", "Account runtime"], ["Aktive Downloads", "Active downloads"], ["Erfolgsquote · Diese Sitzung", "Success rate · This session"], ["Zuletzt verwendet", "Last used"], ["Cooldown / Grund", "Cooldown / reason"],
|
||||
["Noch keine Accounts konfiguriert.", "No accounts configured yet."], ["Noch keine Laufzeitdaten verfügbar.", "No runtime data available yet."], ["Noch nicht in dieser Sitzung", "Not yet in this session"], ["Gerade eben", "Just now"], ["Prüfung", "Checking"], ["Tageslimit", "Daily limit"], ["Cooldown", "Cooldown"],
|
||||
["Noch keine Accounts konfiguriert.", "No accounts configured yet."], ["Noch keine Laufzeitdaten verfügbar.", "No runtime data available yet."], ["Noch nicht in dieser Sitzung", "Not yet in this session"], ["Gerade eben", "Just now"], ["gerade eben", "just now"], ["Prüfung", "Checking"], ["Tageslimit", "Daily limit"], ["Cooldown", "Cooldown"],
|
||||
["aktiver Download", "active download"], ["aktive Downloads", "active downloads"], ["heute", "today"], ["Account deaktiviert", "Account disabled"], ["Tageslimit erreicht", "Daily limit reached"], ["Anmeldung ungültig", "Invalid login"], ["Rate-Limit aktiv", "Rate limit active"], ["Traffic- oder Kontolimit erreicht", "Traffic or account limit reached"], ["Vorübergehender Cooldown", "Temporary cooldown"], ["Provider oder Link vorübergehend nicht verfügbar", "Provider or link temporarily unavailable"],
|
||||
["Accounts zum Herunterladen verwenden", "Use accounts for downloads"], ["Download-Traffic übrig", "Download traffic remaining"], ["Benutzername", "Username"], ["E-Mail", "Email"], ["Verfallsdatum", "Expiration date"], ["Passwort/Zugang", "Password/access"],
|
||||
["Account hinzufügen", "Add account"], ["Ausgewählte prüfen", "Check selected"], ["Ausgewählte entfernen", "Remove selected"], ["Aktivieren", "Enable"], ["Deaktivieren", "Disable"], ["Noch nicht geprüft", "Not checked yet"],
|
||||
["Account hinzufügen", "Add account"], ["Ausgewählte prüfen", "Check selected"], ["Ausgewählte entfernen", "Remove selected"], ["Aktivieren", "Enable"], ["Deaktivieren", "Disable"], ["Noch nicht geprüft", "Not checked yet"], ["Geprüft", "Checked"],
|
||||
["Aktiviert", "Enabled"], ["Aktionen", "Actions"], ["Deaktiviert", "Disabled"], ["Premium aktiv", "Premium active"], ["API-Key aktiv", "API key active"], ["API-Account", "API account"], ["API-Key", "API key"],
|
||||
["Ungültiger API-Key (nicht autorisiert)", "Invalid API key (not authorized)"], ["Free Account", "Free account"], ["Unbeschränkt", "Unlimited"], ["Keine Accounts eingerichtet", "No accounts configured"],
|
||||
["Ablauf, Ziel, Tonspur, Ablageform und Leistung.", "Workflow, destination, audio track, layout and performance."], ["Ziel und Ablauf", "Destination and workflow"], ["Entpacken nach", "Extract to"],
|
||||
|
||||
@@ -373,9 +373,10 @@ function AccountRow({
|
||||
<small>{row.mode}</small>
|
||||
</span>
|
||||
</span>
|
||||
<span className="settings-account-status" role="cell">
|
||||
<span className={`settings-account-status-badge is-${row.status.tone}`}>{row.status.text}</span>
|
||||
</span>
|
||||
<span className="settings-account-status" role="cell">
|
||||
<span className={`settings-account-status-badge is-${row.status.tone}`}>{row.status.text}</span>
|
||||
{row.status.checkedAgo ? <small className="settings-account-status-checked"><span>Geprüft</span> {row.status.checkedAgo}</small> : null}
|
||||
</span>
|
||||
<span className="settings-account-traffic" role="cell">{row.traffic}</span>
|
||||
{renderAccountIdentityCell({ className: "settings-account-username", label: "Benutzername", onCopy: actions.onCopyIdentity, value: row.username })}
|
||||
{renderAccountIdentityCell({ className: "settings-account-email", label: "E-Mail", onCopy: actions.onCopyIdentity, value: row.email })}
|
||||
|
||||
@@ -140,6 +140,7 @@ export interface AccountRowSource {
|
||||
state: AccountStatusSourceState;
|
||||
message: string;
|
||||
premiumUntilMs: number | null;
|
||||
checkedAt?: number;
|
||||
username?: string;
|
||||
email?: string;
|
||||
};
|
||||
@@ -161,6 +162,7 @@ export interface AccountRowViewModel {
|
||||
status: {
|
||||
tone: AccountStatusTone;
|
||||
text: string;
|
||||
checkedAgo: string;
|
||||
};
|
||||
traffic: string;
|
||||
username: string;
|
||||
@@ -634,6 +636,26 @@ function formatExpiry(premiumUntilMs: number | null): string {
|
||||
return new Intl.DateTimeFormat("de-DE").format(new Date(premiumUntilMs));
|
||||
}
|
||||
|
||||
function formatCheckedAgo(checkedAt: number | undefined, nowMs: number): string {
|
||||
if (!checkedAt || !Number.isFinite(checkedAt) || checkedAt <= 0) {
|
||||
return "";
|
||||
}
|
||||
const deltaMs = Math.max(0, nowMs - checkedAt);
|
||||
const minutes = Math.floor(deltaMs / 60_000);
|
||||
if (minutes < 1) {
|
||||
return "gerade eben";
|
||||
}
|
||||
if (minutes < 60) {
|
||||
return `vor ${minutes} Min`;
|
||||
}
|
||||
const hours = Math.floor(minutes / 60);
|
||||
if (hours < 24) {
|
||||
return `vor ${hours} Std`;
|
||||
}
|
||||
const days = Math.floor(hours / 24);
|
||||
return `vor ${days} Tag${days === 1 ? "" : "en"}`;
|
||||
}
|
||||
|
||||
function projectStatus(source: AccountRowSource): { tone: AccountStatusTone; text: string } {
|
||||
if (!source.enabled || source.status.state === "disabled") {
|
||||
return { tone: "disabled", text: "Deaktiviert" };
|
||||
@@ -691,7 +713,7 @@ export function projectAccountRows(
|
||||
icon: ACCOUNT_SERVICE_ICONS[source.service],
|
||||
enabled: source.enabled,
|
||||
selected: selected.has(id),
|
||||
status,
|
||||
status: { ...status, checkedAgo: formatCheckedAgo(source.status.checkedAt, nowMs) },
|
||||
traffic: formatTraffic(source.dailyLimitBytes, source.dailyUsageBytes),
|
||||
username: identity.username,
|
||||
email: identity.email,
|
||||
|
||||
@@ -723,6 +723,20 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.settings-account-status {
|
||||
display: grid;
|
||||
align-content: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.settings-account-status-checked {
|
||||
overflow: hidden;
|
||||
color: var(--ui-text-muted);
|
||||
font-size: 11px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.settings-account-status-badge::before {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
|
||||
Reference in New Issue
Block a user