chore: cleanup login state

This commit is contained in:
2025-03-12 11:26:46 +00:00
parent 0584089d92
commit f028de7c04
7 changed files with 117 additions and 104 deletions

View File

@ -226,7 +226,7 @@ export function normalizeReaction(content: string) {
}
}
export class OfflineError extends Error {}
export class OfflineError extends Error { }
export function throwIfOffline() {
if (isOffline()) {
@ -238,11 +238,13 @@ export function isOffline() {
return !("navigator" in globalThis && globalThis.navigator.onLine);
}
export function isHex(s: string) {
export function isHex(s?: string) {
if (!s) return false;
// 48-57 = 0-9
// 65-90 = A-Z
// 97-122 = a-z
return [...s]
.map(v => v.charCodeAt(0))
.every(v => (v >= 48 && v <= 57) || (v >= 65 && v <= 90) || v >= 97 || v <= 122);
return s.length % 2 == 0 &&
[...s]
.map(v => v.charCodeAt(0))
.every(v => (v >= 48 && v <= 57) || (v >= 65 && v <= 90) || v >= 97 || v <= 122);
}