Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/nowarnings Solve some of the warnings we have on LLM #2732

Closed
wants to merge 8 commits into from
5 changes: 5 additions & 0 deletions .changeset/lazy-paws-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Fix up some warnings at launch
5 changes: 5 additions & 0 deletions .changeset/new-hounds-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/native-ui": patch
---

Remove cycle dependencies
5 changes: 5 additions & 0 deletions .changeset/stupid-students-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

Refactor useIsMounted hook
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ImageDownloadError,
} from "@ledgerhq/live-common/customImage/errors";
import { urlContentToDataUri } from "~/renderer/components/CustomImage/shared";
import { useIsMounted } from "~/renderer/hooks/useIsMounted";
import useIsMounted from "@ledgerhq/live-common/hooks/useIsMounted";

type Props = StepProps & {
onResult: (res: ImageBase64Data) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ export const FirebaseRemoteConfigProvider = ({
});
await remoteConfig().fetchAndActivate();
} catch (error) {
console.error(
`Failed to fetch Firebase remote config with error: ${error}`,
);
if (!unmounted) {
console.error(
`Failed to fetch Firebase remote config with error: ${error}`,
);
}
}
if (!unmounted) {
setLoaded(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { useReceiveNFTsModal } from "../../screens/Nft/NftGallery/ReceiveNFTsMod

const StyledTouchableOpacity = styled(TouchableOpacity)`
background-color: ${props => props.theme.colors.background.main};
margin-bottom: 8;
border-radius: 8;
height: 160;
border-width: 1;
margin-bottom: 8px;
border-radius: 8px;
height: 160px;
border-width: 1px;
border-color: ${props => props.theme.colors.neutral.c60};
border-style: dashed;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Flex, Link, Text } from "@ledgerhq/native-ui";
import React, { ReactNode, useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { AppState, Linking, PermissionsAndroid } from "react-native";
import { useIsMounted } from "../../helpers/useIsMounted";
import useIsMounted from "@ledgerhq/live-common/hooks/useIsMounted";
import QueuedDrawer from "../QueuedDrawer";
import {
bluetoothPermissions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactNode, useCallback, useEffect, useState } from "react";
import { useIsMounted } from "../../helpers/useIsMounted";
import useIsMounted from "@ledgerhq/live-common/hooks/useIsMounted";
import LocationRequired from "../LocationRequired";
import {
checkLocationPermission,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Camera } from "expo-camera";
import useIsMounted from "@ledgerhq/live-common/hooks/useIsMounted";
import { AppState, Linking } from "react-native";
import { useIsMounted } from "../../helpers/useIsMounted";

export default function useCameraPermissions() {
const [permission, requestPermission, checkPermission] =
Expand Down
18 changes: 0 additions & 18 deletions apps/ledger-live-mobile/src/helpers/useIsMounted.ts

This file was deleted.

1 change: 1 addition & 0 deletions apps/ledger-live-mobile/src/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ if (__DEV__ && process.env.NODE_ENV !== "test") {
"Warning: componentWillReceiveProps has been renamed",
"Warning: componentWillUpdate has been renamed",
"Warning: componentWillMount has been renamed",
"exported from 'deprecated-react-native-prop-types'.", // https://github.com/facebook/react-native/issues/33557#issuecomment-1093083115
]);
} catch (e) {
console.warn(e);
Expand Down
2 changes: 1 addition & 1 deletion libs/ledger-live-common/src/data/icons/svg/FTM.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion libs/ledger-live-common/src/data/icons/svg/SGB.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef } from "react";

// Stateless hook that returns a function which, when called, indicates if the component
// using the hook is currently mounted or not
export const useIsMounted = () => {
const useIsMounted = () => {
const mountedRef = useRef(false);
const isMounted = useCallback(() => mountedRef.current, []);

Expand All @@ -16,3 +16,5 @@ export const useIsMounted = () => {

return isMounted;
};

export default useIsMounted;
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { LiveAppManifest, Loadable } from "../../types";
import api from "./api";
import { FilterParams } from "../../filters";
import { getEnv } from "../../../env";
import useIsMounted from "../../../hooks/useIsMounted";

const initialState: Loadable<LiveAppRegistry> = {
isLoading: false,
Expand Down Expand Up @@ -74,6 +75,7 @@ export function RemoteLiveAppProvider({
parameters,
updateFrequency,
}: LiveAppProviderProps): JSX.Element {
const isMounted = useIsMounted();
const [state, setState] = useState<Loadable<LiveAppRegistry>>(initialState);
const [provider, setProvider] = useState<string>(initialProvider);

Expand Down Expand Up @@ -101,6 +103,7 @@ export function RemoteLiveAppProvider({
branches,
});

if (!isMounted()) return;
setState(() => ({
isLoading: false,
value: {
Expand All @@ -114,13 +117,15 @@ export function RemoteLiveAppProvider({
error: null,
}));
} catch (error) {
if (!isMounted()) return;
setState((currentState) => ({
...currentState,
isLoading: false,
error,
}));
}
}, [allowDebugApps, allowExperimentalApps, providerURL]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [allowDebugApps, allowExperimentalApps, providerURL, isMounted]);

const value: LiveAppContextType = useMemo(
() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import styled from "styled-components/native";
import { CheckAloneMedium } from "@ledgerhq/icons-ui/native";

import { Item, ItemStatus } from "../types";
import { Flex } from "../..";
import { Text, ProgressLoader } from "../../..";
import Flex from "../../Flex";
import Text from "../../../Text";
import ProgressLoader from "../../../Loader/ProgressLoader";

export type Props = {
item: Item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { Theme } from "src/styles/theme";
import styled from "styled-components/native";

import { Item, ItemStatus } from "../types";
import { Flex } from "../..";
import { Text, Tag } from "../../..";
import Flex from "../../Flex";
import Text from "../../../Text";
import Tag from "../../../tags/Tag";
import TimelineIndicator from "./TimelineIndicator";

export type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

import TimelineItem from "./TimelineItem";
import { Flex } from "../..";
import Flex from "../../Flex";
import { BaseStyledProps } from "src/components/styled";
import { Item, ItemStatus } from "../types";

Expand Down