From dce2282e1a520bd9fc052e2d068b8a6d194c62d5 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 14 Aug 2023 22:17:53 +0000 Subject: [PATCH] fix: prevent app to jump to first device after another device name was changed --- .../modals/SettingsChangeDeviceDisplayName/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Screens/Device/modals/SettingsChangeDeviceDisplayName/index.js b/src/Screens/Device/modals/SettingsChangeDeviceDisplayName/index.js index 4f75a73..54c6005 100644 --- a/src/Screens/Device/modals/SettingsChangeDeviceDisplayName/index.js +++ b/src/Screens/Device/modals/SettingsChangeDeviceDisplayName/index.js @@ -1,5 +1,9 @@ import { useContext } from "react"; -import { AppContext, Constants } from "../../../../utils"; +import { + AppContext, + AppSelectedUserDevice, + Constants, +} from "../../../../utils"; import { useTranslation } from "react-i18next"; import { MyTextInputModalContent } from "../../../../Components/Modal"; @@ -18,6 +22,11 @@ export default function SettingsChangeDeviceDisplayNameModalContent({ if (foundIndex !== -1) { newArr[foundIndex].displayName = newDeviceDisplayName; + + AppSelectedUserDevice.current.routeName = newDeviceDisplayName; + + // this timeout is needed as the app will navigate to the first device in appContext.devices without to navigate back to the updated device + setTimeout(() => navigation.navigate(newDeviceDisplayName), 50); } return newArr;