fix(auth): handles expired tokens correctly

This commit is contained in:
2025-05-09 01:53:44 -04:00
parent b8e94f6409
commit 23ab1cc85d
3 changed files with 305 additions and 235 deletions

View File

@@ -66,3 +66,24 @@ function internal_time_ago(time) {
}
return time;
}
// Function to format time duration similar to C#'s TimeSpan
export function formatDuration(milliseconds) {
// Ensure we're working with a positive number
const ms = Math.abs(milliseconds);
const days = Math.floor(ms / (24 * 60 * 60 * 1000));
const hours = Math.floor((ms % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
const minutes = Math.floor((ms % (60 * 60 * 1000)) / (60 * 1000));
const seconds = Math.floor((ms % (60 * 1000)) / 1000);
// Format the duration like "1d 2h 3m 4s" or just the relevant parts
const parts = [];
if (days > 0) parts.push(`${days}d`);
if (hours > 0 || days > 0) parts.push(`${hours}h`);
if (minutes > 0 || hours > 0 || days > 0) parts.push(`${minutes}m`);
parts.push(`${seconds}s`);
return parts.join(' ');
}