diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-01-04 00:31:31 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-01-04 00:31:31 +0300 |
| commit | 3f15d21f1321932324dffc8c1cacee7dce5b9dc4 (patch) | |
| tree | ef374238a513c47999d0def07e82365d12cfea34 | |
| parent | a6b36236345678c5c0a5c0ef42d5f5f6ebb5f5bf (diff) | |
fix #3622
| -rw-r--r-- | web/assets/js/util/index.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js index 13bf68b1..e69f3341 100644 --- a/web/assets/js/util/index.js +++ b/web/assets/js/util/index.js @@ -142,7 +142,7 @@ class RandomUtil { let length = 32; if ([SSMethods.BLAKE3_AES_128_GCM].includes(method)) { - length = 16; + length = 16; } const array = new Uint8Array(length); @@ -154,28 +154,28 @@ class RandomUtil { static randomBase32String(length = 16) { const array = new Uint8Array(length); - + window.crypto.getRandomValues(array); - + const base32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; let result = ''; let bits = 0; let buffer = 0; - + for (let i = 0; i < array.length; i++) { buffer = (buffer << 8) | array[i]; bits += 8; - + while (bits >= 5) { bits -= 5; result += base32Chars[(buffer >>> bits) & 0x1F]; } } - + if (bits > 0) { result += base32Chars[(buffer << (5 - bits)) & 0x1F]; } - + return result; } } @@ -908,7 +908,10 @@ class IntlUtil { const language = LanguageManager.getLanguage() const now = new Date() - const diff = Math.round((date - now) / (1000 * 60 * 60 * 24)) + // Handle delayed start (negative expiryTime values) + const diff = date < 0 + ? Math.round(date / (1000 * 60 * 60 * 24)) + : Math.round((date - now) / (1000 * 60 * 60 * 24)) const formatter = new Intl.RelativeTimeFormat(language, { numeric: 'auto' }) return formatter.format(diff, 'day'); |
