Make React compiler happy about some frankly non-issues
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
b597abf567
commit
72f155640d
3 changed files with 26 additions and 32 deletions
|
@ -27,7 +27,7 @@ type Props = {
|
||||||
const MATCH_SYSTEM_THEME_ID = "MATCH_SYSTEM_THEME_ID";
|
const MATCH_SYSTEM_THEME_ID = "MATCH_SYSTEM_THEME_ID";
|
||||||
|
|
||||||
const QuickThemeSwitcher: React.FC<Props> = ({ requestClose }) => {
|
const QuickThemeSwitcher: React.FC<Props> = ({ requestClose }) => {
|
||||||
const orderedThemes = useMemo(getOrderedThemes, []);
|
const orderedThemes = useMemo(() => getOrderedThemes(), []);
|
||||||
|
|
||||||
const themeState = useTheme();
|
const themeState = useTheme();
|
||||||
const nonHighContrast = findNonHighContrastTheme(themeState.theme);
|
const nonHighContrast = findNonHighContrastTheme(themeState.theme);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Please see LICENSE files in the repository root for full details.
|
* Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { ClientEvent, MatrixClient, MatrixEventEvent, Room } from "matrix-js-sdk/src/matrix";
|
import { ClientEvent, MatrixClient, MatrixEventEvent, Room } from "matrix-js-sdk/src/matrix";
|
||||||
import { throttle } from "lodash";
|
import { throttle } from "lodash";
|
||||||
|
|
||||||
|
@ -42,14 +42,12 @@ export function useUnreadThreadRooms(forceComputation: boolean): Result {
|
||||||
setResult(computeUnreadThreadRooms(mxClient, msc3946ProcessDynamicPredecessor, settingTACOnlyNotifs));
|
setResult(computeUnreadThreadRooms(mxClient, msc3946ProcessDynamicPredecessor, settingTACOnlyNotifs));
|
||||||
}, [mxClient, msc3946ProcessDynamicPredecessor, settingTACOnlyNotifs]);
|
}, [mxClient, msc3946ProcessDynamicPredecessor, settingTACOnlyNotifs]);
|
||||||
|
|
||||||
// The exhautive deps lint rule can't compute dependencies here since it's not a plain inline func.
|
const scheduleUpdate = useMemo(
|
||||||
// We make this as simple as possible so its only dep is doUpdate itself.
|
() =>
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
throttle(doUpdate, MIN_UPDATE_INTERVAL_MS, {
|
||||||
const scheduleUpdate = useCallback(
|
leading: false,
|
||||||
throttle(doUpdate, MIN_UPDATE_INTERVAL_MS, {
|
trailing: true,
|
||||||
leading: false,
|
}),
|
||||||
trailing: true,
|
|
||||||
}),
|
|
||||||
[doUpdate],
|
[doUpdate],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||||
Please see LICENSE files in the repository root for full details.
|
Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
|
|
||||||
import type { Map as MapLibreMap } from "maplibre-gl";
|
import type { Map as MapLibreMap } from "maplibre-gl";
|
||||||
import { createMap } from "./map";
|
import { createMap } from "./map";
|
||||||
|
@ -26,29 +26,25 @@ interface UseMapProps {
|
||||||
*/
|
*/
|
||||||
export const useMap = ({ interactive, bodyId, onError }: UseMapProps): MapLibreMap | undefined => {
|
export const useMap = ({ interactive, bodyId, onError }: UseMapProps): MapLibreMap | undefined => {
|
||||||
const cli = useMatrixClientContext();
|
const cli = useMatrixClientContext();
|
||||||
const [map, setMap] = useState<MapLibreMap>();
|
|
||||||
|
|
||||||
useEffect(
|
const map = useMemo(() => {
|
||||||
() => {
|
try {
|
||||||
try {
|
return createMap(cli, !!interactive, bodyId, onError);
|
||||||
setMap(createMap(cli, !!interactive, bodyId, onError));
|
} catch (error) {
|
||||||
} catch (error) {
|
console.error("Error encountered in useMap", error);
|
||||||
console.error("Error encountered in useMap", error);
|
if (error instanceof Error) {
|
||||||
if (error instanceof Error) {
|
onError?.(error);
|
||||||
onError?.(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return () => {
|
}
|
||||||
if (map) {
|
}, [bodyId, cli, interactive, onError]);
|
||||||
map.remove();
|
|
||||||
setMap(undefined);
|
// cleanup
|
||||||
}
|
useEffect(() => {
|
||||||
};
|
if (!map) return;
|
||||||
},
|
return () => {
|
||||||
// map is excluded as a dependency
|
map.remove();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
};
|
||||||
[interactive, bodyId, onError],
|
}, [map]);
|
||||||
);
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue