fix: prevent app to jump to first device after another device name was changed

main
alex 2023-08-14 22:17:53 +00:00
parent 06c22b6a5e
commit dce2282e1a
1 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,9 @@
import { useContext } from "react"; import { useContext } from "react";
import { AppContext, Constants } from "../../../../utils"; import {
AppContext,
AppSelectedUserDevice,
Constants,
} from "../../../../utils";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { MyTextInputModalContent } from "../../../../Components/Modal"; import { MyTextInputModalContent } from "../../../../Components/Modal";
@ -18,6 +22,11 @@ export default function SettingsChangeDeviceDisplayNameModalContent({
if (foundIndex !== -1) { if (foundIndex !== -1) {
newArr[foundIndex].displayName = newDeviceDisplayName; 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; return newArr;