CODEBASE: Fix lint errors 2 (#1756)

This commit is contained in:
catloversg
2024-11-07 14:09:11 +07:00
committed by GitHub
parent e3c10e9f0f
commit 36c143b687
48 changed files with 267 additions and 146 deletions

View File

@@ -8,8 +8,9 @@ import Typography from "@mui/material/Typography";
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import { SidebarItem, ICreateProps as IItemProps } from "./SidebarItem";
import { SidebarItem, ICreateProps as IItemProps, type SidebarItemProps } from "./SidebarItem";
import type { Page } from "../../ui/Router";
import type { PartialRecord } from "../../Types/Record";
type SidebarAccordionProps = {
key_: string;
@@ -19,9 +20,12 @@ type SidebarAccordionProps = {
items: (IItemProps | boolean)[];
icon: React.ReactElement["type"];
sidebarOpen: boolean;
classes: any;
classes: Record<"listitem" | "active", string>;
};
type ClickFnCacheKeyType = (page: Page) => void;
type ClickFnCacheValueType = PartialRecord<Page, SidebarItemProps["clickFn"]>;
// We can't useCallback for this, because in the items map it would be
// called a changing number of times, and hooks can't be called in loops. So
// we set up this explicit cache of function objects instead.
@@ -30,7 +34,7 @@ type SidebarAccordionProps = {
// WeakMap prevents memory leaks. We won't drop slices of the cache too soon,
// because the fn keys are themselves memoized elsewhere, which keeps them
// alive and thus keeps the WeakMap entries alive.
const clickFnCache = new WeakMap();
const clickFnCache = new WeakMap<ClickFnCacheKeyType, ClickFnCacheValueType>();
function getClickFn(toWrap: (page: Page) => void, page: Page) {
let first = clickFnCache.get(toWrap);
if (first === undefined) {

View File

@@ -18,7 +18,7 @@ export interface ICreateProps {
export interface SidebarItemProps extends ICreateProps {
clickFn: () => void;
flash: boolean;
classes: any;
classes: Record<"listitem" | "active", string>;
sidebarOpen: boolean;
}