chore: Minor typescript improves
This commit is contained in:
@@ -49,7 +49,7 @@ export default function ContextMenu({
|
|||||||
}: Props) {
|
}: Props) {
|
||||||
const previousVisible = usePrevious(rest.visible);
|
const previousVisible = usePrevious(rest.visible);
|
||||||
const maxHeight = useMenuHeight(rest.visible, rest.unstable_disclosureRef);
|
const maxHeight = useMenuHeight(rest.visible, rest.unstable_disclosureRef);
|
||||||
const backgroundRef = React.useRef();
|
const backgroundRef = React.useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (rest.visible && !previousVisible) {
|
if (rest.visible && !previousVisible) {
|
||||||
@@ -79,8 +79,7 @@ export default function ContextMenu({
|
|||||||
// kind of hacky, but this is an effective way of telling which way
|
// kind of hacky, but this is an effective way of telling which way
|
||||||
// the menu will _actually_ be placed when taking into account screen
|
// the menu will _actually_ be placed when taking into account screen
|
||||||
// positioning.
|
// positioning.
|
||||||
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
|
const topAnchor = props.style?.top === "0";
|
||||||
const topAnchor = props.style.top === "0";
|
|
||||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'placement' does not exist on type 'Extra... Remove this comment to see the full error message
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'placement' does not exist on type 'Extra... Remove this comment to see the full error message
|
||||||
const rightAnchor = props.placement === "bottom-end";
|
const rightAnchor = props.placement === "bottom-end";
|
||||||
|
|
||||||
@@ -90,7 +89,6 @@ export default function ContextMenu({
|
|||||||
dir="auto"
|
dir="auto"
|
||||||
topAnchor={topAnchor}
|
topAnchor={topAnchor}
|
||||||
rightAnchor={rightAnchor}
|
rightAnchor={rightAnchor}
|
||||||
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
|
||||||
ref={backgroundRef}
|
ref={backgroundRef}
|
||||||
style={
|
style={
|
||||||
maxHeight && topAnchor
|
maxHeight && topAnchor
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function loadSessionsFromCookie(): Session[] {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function useSessions() {
|
export default function useSessions(): [Session[], () => void] {
|
||||||
const [sessions, setSessions] = React.useState(loadSessionsFromCookie);
|
const [sessions, setSessions] = React.useState(loadSessionsFromCookie);
|
||||||
const reload = React.useCallback(() => {
|
const reload = React.useCallback(() => {
|
||||||
setSessions(loadSessionsFromCookie());
|
setSessions(loadSessionsFromCookie());
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ function AccountMenu(props: Props) {
|
|||||||
}, [menu, theme, previousTheme]);
|
}, [menu, theme, previousTheme]);
|
||||||
|
|
||||||
const actions = React.useMemo(() => {
|
const actions = React.useMemo(() => {
|
||||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'filter' does not exist on type 'Session[... Remove this comment to see the full error message
|
|
||||||
const otherSessions = sessions.filter(
|
const otherSessions = sessions.filter(
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'session' implicitly has an 'any' type.
|
|
||||||
(session) => session.teamId !== team.id && session.url !== team.url
|
(session) => session.teamId !== team.id && session.url !== team.url
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -69,9 +67,10 @@ function AccountMenu(props: Props) {
|
|||||||
createAction({
|
createAction({
|
||||||
name: t("Switch team"),
|
name: t("Switch team"),
|
||||||
section: "account",
|
section: "account",
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'session' implicitly has an 'any' type.
|
|
||||||
children: otherSessions.map((session) => ({
|
children: otherSessions.map((session) => ({
|
||||||
|
id: session.url,
|
||||||
name: session.name,
|
name: session.name,
|
||||||
|
section: "account",
|
||||||
icon: <Logo alt={session.name} src={session.logoUrl} />,
|
icon: <Logo alt={session.name} src={session.logoUrl} />,
|
||||||
perform: () => (window.location.href = session.url),
|
perform: () => (window.location.href = session.url),
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -24,11 +24,8 @@ function RecentSearches() {
|
|||||||
<Heading>{t("Recent searches")}</Heading>
|
<Heading>{t("Recent searches")}</Heading>
|
||||||
<List>
|
<List>
|
||||||
{searches.recent.map((searchQuery) => (
|
{searches.recent.map((searchQuery) => (
|
||||||
<ListItem>
|
<ListItem key={searchQuery.id}>
|
||||||
<RecentSearch
|
<RecentSearch to={searchUrl(searchQuery.query)}>
|
||||||
key={searchQuery.id}
|
|
||||||
to={searchUrl(searchQuery.query)}
|
|
||||||
>
|
|
||||||
{searchQuery.query}
|
{searchQuery.query}
|
||||||
<Tooltip tooltip={t("Remove search")} delay={150}>
|
<Tooltip tooltip={t("Remove search")} delay={150}>
|
||||||
<RemoveButton
|
<RemoveButton
|
||||||
|
|||||||
Reference in New Issue
Block a user