mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-07-07 21:48:03 +02:00
chore: linting
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
type AutoHeightOptions = {
|
||||
interface AutoHeightOptions {
|
||||
includeParentBox?: boolean;
|
||||
includeSelfBox?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export function useAutoHeight<T extends HTMLElement = HTMLDivElement>(
|
||||
deps: React.DependencyList = [],
|
||||
@@ -22,18 +22,18 @@ export function useAutoHeight<T extends HTMLElement = HTMLDivElement>(
|
||||
const el = ref.current;
|
||||
if (!el) return 0;
|
||||
|
||||
const base = el.getBoundingClientRect().height || 0;
|
||||
const base = el.getBoundingClientRect().height ?? 0;
|
||||
|
||||
let extra = 0;
|
||||
|
||||
if (options.includeParentBox && el.parentElement) {
|
||||
const cs = getComputedStyle(el.parentElement);
|
||||
const paddingY =
|
||||
(parseFloat(cs.paddingTop || "0") || 0) +
|
||||
(parseFloat(cs.paddingBottom || "0") || 0);
|
||||
(parseFloat(cs.paddingTop ?? "0") ?? 0) +
|
||||
(parseFloat(cs.paddingBottom ?? "0") ?? 0);
|
||||
const borderY =
|
||||
(parseFloat(cs.borderTopWidth || "0") || 0) +
|
||||
(parseFloat(cs.borderBottomWidth || "0") || 0);
|
||||
(parseFloat(cs.borderTopWidth ?? "0") ?? 0) +
|
||||
(parseFloat(cs.borderBottomWidth ?? "0") ?? 0);
|
||||
const isBorderBox = cs.boxSizing === "border-box";
|
||||
if (isBorderBox) {
|
||||
extra += paddingY + borderY;
|
||||
@@ -43,11 +43,11 @@ export function useAutoHeight<T extends HTMLElement = HTMLDivElement>(
|
||||
if (options.includeSelfBox) {
|
||||
const cs = getComputedStyle(el);
|
||||
const paddingY =
|
||||
(parseFloat(cs.paddingTop || "0") || 0) +
|
||||
(parseFloat(cs.paddingBottom || "0") || 0);
|
||||
(parseFloat(cs.paddingTop ?? "0") ?? 0) +
|
||||
(parseFloat(cs.paddingBottom ?? "0") ?? 0);
|
||||
const borderY =
|
||||
(parseFloat(cs.borderTopWidth || "0") || 0) +
|
||||
(parseFloat(cs.borderBottomWidth || "0") || 0);
|
||||
(parseFloat(cs.borderTopWidth ?? "0") ?? 0) +
|
||||
(parseFloat(cs.borderBottomWidth ?? "0") ?? 0);
|
||||
const isBorderBox = cs.boxSizing === "border-box";
|
||||
if (isBorderBox) {
|
||||
extra += paddingY + borderY;
|
||||
@@ -55,7 +55,7 @@ export function useAutoHeight<T extends HTMLElement = HTMLDivElement>(
|
||||
}
|
||||
|
||||
const dpr =
|
||||
typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
||||
typeof window !== "undefined" ? (window.devicePixelRatio ?? 1) : 1;
|
||||
const total = Math.ceil((base + extra) * dpr) / dpr;
|
||||
|
||||
return total;
|
||||
@@ -74,7 +74,9 @@ export function useAutoHeight<T extends HTMLElement = HTMLDivElement>(
|
||||
|
||||
const ro = new ResizeObserver(() => {
|
||||
const next = measure();
|
||||
requestAnimationFrame(() => setHeight(next));
|
||||
requestAnimationFrame(() => {
|
||||
setHeight(next);
|
||||
});
|
||||
});
|
||||
|
||||
ro.observe(el);
|
||||
|
||||
@@ -314,9 +314,9 @@ export function useBrowserDownload() {
|
||||
invoke("cancel_download", {
|
||||
browserStr: progress.browser,
|
||||
version: progress.version,
|
||||
}).catch((err) =>
|
||||
console.error("Failed to cancel download:", err),
|
||||
);
|
||||
}).catch((err) => {
|
||||
console.error("Failed to cancel download:", err);
|
||||
});
|
||||
dismissToast(toastId);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -15,7 +15,6 @@ export function useBrowserState(
|
||||
_isUpdating: (browser: string) => boolean,
|
||||
launchingProfiles: Set<string>,
|
||||
stoppingProfiles: Set<string>,
|
||||
_crossOsUnlocked = false,
|
||||
) {
|
||||
const [isClient, setIsClient] = useState(false);
|
||||
|
||||
|
||||
@@ -30,14 +30,14 @@ export function useCloudAuth(): UseCloudAuthReturn {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadUser();
|
||||
void loadUser();
|
||||
|
||||
const unlistenExpired = listen("cloud-auth-expired", () => {
|
||||
setAuthState(null);
|
||||
});
|
||||
|
||||
const unlistenChanged = listen("cloud-auth-changed", () => {
|
||||
loadUser();
|
||||
void loadUser();
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -43,11 +43,15 @@ export function useCommercialTrial(): UseCommercialTrialReturn {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
checkTrialStatus();
|
||||
void checkTrialStatus();
|
||||
|
||||
// Check trial status every minute to update the countdown
|
||||
const interval = setInterval(checkTrialStatus, 60000);
|
||||
return () => clearInterval(interval);
|
||||
const interval = setInterval(() => {
|
||||
void checkTrialStatus();
|
||||
}, 60000);
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [checkTrialStatus]);
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,6 @@ interface CommonControlledStateProps<T> {
|
||||
defaultValue?: T;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function useControlledState<T, Rest extends any[] = []>(
|
||||
props: CommonControlledStateProps<T> & {
|
||||
onChange?: (value: T, ...args: Rest) => void;
|
||||
@@ -14,7 +13,7 @@ export function useControlledState<T, Rest extends any[] = []>(
|
||||
const { value, defaultValue, onChange } = props;
|
||||
|
||||
const [state, setInternalState] = React.useState<T>(
|
||||
value !== undefined ? value : (defaultValue as T),
|
||||
value ?? (defaultValue as T),
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
@@ -120,7 +120,7 @@ export function usePermissions(): UsePermissionsReturn {
|
||||
|
||||
// Initialize platform detection and start interval checking
|
||||
useEffect(() => {
|
||||
const initializePlatform = async () => {
|
||||
const initializePlatform = () => {
|
||||
try {
|
||||
// Detect platform - on macOS we need permissions, on others we don't
|
||||
const userAgent = navigator.userAgent;
|
||||
@@ -142,7 +142,7 @@ export function usePermissions(): UsePermissionsReturn {
|
||||
}
|
||||
};
|
||||
|
||||
initializePlatform().catch(console.error);
|
||||
initializePlatform();
|
||||
}, []);
|
||||
|
||||
// Set up interval checking when platform is determined
|
||||
|
||||
@@ -169,7 +169,9 @@ export function useProfileEvents(): UseProfileEventsReturn {
|
||||
void syncRunningStates();
|
||||
}, 30000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [profiles]);
|
||||
|
||||
return {
|
||||
|
||||
@@ -16,20 +16,24 @@ export function useTeamLocks(currentUserId?: string) {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
fetchLocks();
|
||||
void fetchLocks();
|
||||
|
||||
const unlistenAcquired = listen<{ profileId: string }>(
|
||||
"team-lock-acquired",
|
||||
() => fetchLocks(),
|
||||
() => void fetchLocks(),
|
||||
);
|
||||
const unlistenReleased = listen<{ profileId: string }>(
|
||||
"team-lock-released",
|
||||
() => fetchLocks(),
|
||||
() => void fetchLocks(),
|
||||
);
|
||||
|
||||
return () => {
|
||||
unlistenAcquired.then((fn) => fn());
|
||||
unlistenReleased.then((fn) => fn());
|
||||
void unlistenAcquired.then((fn) => {
|
||||
fn();
|
||||
});
|
||||
void unlistenReleased.then((fn) => {
|
||||
fn();
|
||||
});
|
||||
};
|
||||
}, [fetchLocks]);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export function useWayfernTerms(): UseWayfernTermsReturn {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
checkTerms();
|
||||
void checkTerms();
|
||||
}, [checkTerms]);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user