diff --git a/app/components/GoogleButtom.tsx b/app/components/GoogleButtom.tsx index 526746e..cd4e47a 100644 --- a/app/components/GoogleButtom.tsx +++ b/app/components/GoogleButtom.tsx @@ -14,7 +14,6 @@ // import { Text, TextProps } from "./Text"; // import { useAppTheme } from "@/utils/useAppTheme"; - // import { useStores } from "@/models"; // import * as WebBrowser from "expo-web-browser"; diff --git a/app/models/Firebase.test.ts b/app/models/Firebase.test.ts index c160089..429af6c 100644 --- a/app/models/Firebase.test.ts +++ b/app/models/Firebase.test.ts @@ -5,5 +5,3 @@ test("can be created", () => { expect(instance).toBeTruthy() }) - - diff --git a/app/models/Firebase.ts b/app/models/Firebase.ts index 77721b4..dc2b2d9 100644 --- a/app/models/Firebase.ts +++ b/app/models/Firebase.ts @@ -15,5 +15,3 @@ export interface Firebase extends Instance {} export interface FirebaseSnapshotOut extends SnapshotOut {} export interface FirebaseSnapshotIn extends SnapshotIn {} export const createFirebaseDefaultModel = () => types.optional(FirebaseModel, {}) - - diff --git a/app/navigators/AppNavigator.tsx b/app/navigators/AppNavigator.tsx index b17ccae..344c00c 100644 --- a/app/navigators/AppNavigator.tsx +++ b/app/navigators/AppNavigator.tsx @@ -95,7 +95,7 @@ export const AppNavigator = observer(function AppNavigator(props: NavigationProp const { themeScheme, navigationTheme, setThemeContextOverride, ThemeProvider } = useThemeProvider() - const exitRoutes = ["welcome","Demo"] // Add any other routes that should exit the app here + const exitRoutes = ["welcome", "Demo"] // Add any other routes that should exit the app here // This hook will handle the back button on Android and exit the app if the user is on an exit route // You can customize the exit routes by modifying the `exitRoutes` array useBackButtonHandler((routeName) => exitRoutes.includes(routeName)) diff --git a/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx b/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx index fc761b1..0452300 100644 --- a/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx +++ b/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx @@ -9,6 +9,7 @@ import { DemoTabParamList, DemoTabScreenProps } from "../../navigators/DemoNavig import type { Theme, ThemedStyle } from "@/theme" import { $styles } from "@/theme" import { useSafeAreaInsetsStyle } from "../../utils/useSafeAreaInsetsStyle" +import { useIsMounted } from "../../utils/useIsMounted" import * as Demos from "./demos" import { DrawerIconButton } from "./DrawerIconButton" import SectionListWithKeyboardAwareScrollView from "./SectionListWithKeyboardAwareScrollView" @@ -99,6 +100,7 @@ export const DemoShowroomScreen: FC> = const menuRef = useRef>(null) const route = useRoute>() const params = route.params + const isMounted = useIsMounted() const { themed, theme } = useAppTheme() @@ -110,39 +112,66 @@ export const DemoShowroomScreen: FC> = } }, [open]) - const handleScroll = useCallback((sectionIndex: number, itemIndex = 0) => { - try { - listRef.current?.scrollToLocation({ - animated: true, - itemIndex, - sectionIndex, - viewPosition: 0.25, - }) - } catch (e) { - console.error(e) - } - }, []) + const handleScroll = useCallback( + (sectionIndex: number, itemIndex = 0) => { + if (!isMounted()) return + + try { + listRef.current?.scrollToLocation({ + animated: true, + itemIndex, + sectionIndex, + viewPosition: 0.25, + }) + } catch (e) { + // Silently handle scroll errors to prevent console spam + // Only log in development mode + if (__DEV__) { + console.warn("Scroll error:", e) + } + } + }, + [isMounted], + ) // handle Web links useEffect(() => { - if (params !== undefined && Object.keys(params).length > 0) { - const demoValues = Object.values(Demos) - const findSectionIndex = demoValues.findIndex( - (x) => x.name.toLowerCase() === params.queryIndex, - ) - let findItemIndex = 0 - if (params.itemIndex) { - try { - findItemIndex = demoValues[findSectionIndex] - .data({ themed, theme }) - .findIndex((u) => slugify(translate(u.props.name)) === params.itemIndex) - } catch (err) { - console.error(err) + if (!isMounted() || !params || Object.keys(params).length === 0) { + return + } + + const demoValues = Object.values(Demos) + const findSectionIndex = demoValues.findIndex( + (x) => x.name.toLowerCase() === params.queryIndex, + ) + + if (findSectionIndex === -1) { + return + } + + let findItemIndex = 0 + if (params.itemIndex) { + try { + const demoData = demoValues[findSectionIndex]?.data({ themed, theme }) + if (demoData) { + findItemIndex = demoData.findIndex( + (u) => slugify(translate(u.props.name)) === params.itemIndex, + ) + if (findItemIndex === -1) { + findItemIndex = 0 + } + } + } catch (err) { + // Silently handle translation errors to prevent console spam + // Only log in development mode + if (__DEV__) { + console.warn("Translation error for item index:", err) } + findItemIndex = 0 } - handleScroll(findSectionIndex, findItemIndex) } - }, [handleScroll, params, theme, themed]) + handleScroll(findSectionIndex, findItemIndex) + }, [handleScroll, params, theme, themed, isMounted]) const scrollToIndexFailed = (info: { index: number diff --git a/app/services/Firebase/firebase.ts b/app/services/Firebase/firebase.ts index 4053d81..b07ecf6 100644 --- a/app/services/Firebase/firebase.ts +++ b/app/services/Firebase/firebase.ts @@ -1,7 +1,7 @@ // Import the functions you need from the SDKs you need -import { initializeApp } from "firebase/app"; -import { getAnalytics } from "firebase/analytics"; -import { getAuth } from "firebase/auth"; +import { initializeApp } from "firebase/app" +import { getAnalytics } from "firebase/analytics" +import { getAuth } from "firebase/auth" // import { getFirestore } from "firebase/firestore"; // import { getStorage } from "firebase/storage"; // import { getFunctions } from "firebase/functions"; @@ -18,9 +18,9 @@ const firebaseConfig = { storageBucket: "dooit-5c76d.firebasestorage.app", messagingSenderId: "477979903432", appId: "1:477979903432:web:3c6d87a5dc4424887cecfd", - measurementId: "G-12ZZX5PBG0" -}; + measurementId: "G-12ZZX5PBG0", +} // Initialize Firebase -const app = initializeApp(firebaseConfig); -const analytics = getAnalytics(app); \ No newline at end of file +const app = initializeApp(firebaseConfig) +const analytics = getAnalytics(app) diff --git a/yarn.lock b/yarn.lock index 2928bae..69cb200 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2944,11 +2944,6 @@ resolved "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz" integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g== -"@unrs/resolver-binding-darwin-arm64@1.7.8": - version "1.7.8" - resolved "https://registry.npmjs.org/@unrs/resolver-binding-darwin-arm64/-/resolver-binding-darwin-arm64-1.7.8.tgz" - integrity sha512-rsRK8T7yxraNRDmpFLZCWqpea6OlXPNRRCjWMx24O1V86KFol7u2gj9zJCv6zB1oJjtnzWceuqdnCgOipFcJPA== - "@urql/core@^5.0.6", "@urql/core@^5.1.1": version "5.1.1" resolved "https://registry.npmjs.org/@urql/core/-/core-5.1.1.tgz" @@ -5617,11 +5612,6 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.3.2: - version "2.3.3" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== - function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" @@ -7124,11 +7114,6 @@ lighthouse-logger@^1.0.0: debug "^2.6.9" marky "^1.2.2" -lightningcss-darwin-arm64@1.27.0: - version "1.27.0" - resolved "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.27.0.tgz" - integrity sha512-Gl/lqIXY+d+ySmMbgDf0pgaWSqrWYxVHoc88q+Vhf2YNzZ8DwoRzGt5NZDVqqIW5ScpSnmmjcgXP87Dn2ylSSQ== - lightningcss@~1.27.0: version "1.27.0" resolved "https://registry.npmjs.org/lightningcss/-/lightningcss-1.27.0.tgz"