Closed rozele closed 2 days ago
One thing I'd consider is exposing a function to set the Property rather than relying on magic strings.
ReactNativeAsyncStorage::SetDatabasePath(propertyBag, path)
Ideally that would be exposed in the idl file as a public method. -- I dont know how strict the current API is about ensuring that all public APIs are part of the idl interface.
Looks like something happened to the line endings, creating a huge diff. Will need to redo this commit.
This PR has been marked as stale due to inactivity. Please address any comments within 7 days or it will be closed.
Summary
WinAppSDK apps do not support the current methods for setting / retrieving the DB path for the default storage in @react-native-async-storage/async-storage. Specifically, winrt::CoreApplication::Properties() causes a crashes on WinAppSDK.
To work around this, this change adds a specific namespaced key (ReactNativeAsyncStorage.Path) to the ReactPropertyBag for apps to register the overridden DB path for WinAppSDK apps (or apps that otherwise cannot use winrt::CoreApplication::Properties()).
Test Plan
Compiled with WinAppSDK build of react-native-windows, set ReactNativeAsyncStorage.Path on the ReactPropertyBag for InstanceSettings when initializing the react-native-windows ReactHost, and confirmed the sqlite DB is written to the correct location.