mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-11-01 18:59:10 +08:00
This patch does a few things to allow network throttling conditions to persist. 1: It enhances `Setting` with custom serializer support. This is because 2: All fields on `NetworkManager.Conditions` values are considered to uniquely identify instances, and one of those fields is a title, which may or may not be localized. Since localization strings may change (or users might decide to use different locales between sessions), when instances are persisted, localized titles should not be irrecoverably baked. Therefore 3. A custom serializer "massages" the serialization data to properly persist these titles, using i18n keys when needed, or the baked title when these values are user-provided and no localization is used. In the future, it might be worthwhile to consider avoiding mixing up presentation state (e.g.: displayed titles) with behavioral state (e.g.: the throttling amounts). In this particular case, the title (along with other properties) doubles as both part of group of fields which (loosely) uniquely identify instances, as well as the literal string displayed in the UI, which leads to these complications. Fixing this however does not seem to be in the scope of this bug. Tracked by bug 1219425. R=mathias@chromium.org Bug: 986267 Change-Id: I47d42d454f945412e97b5e747a6253d54f888ee0 Signed-off-by: Victor Porof <victorporof@chromium.com> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2947255 Commit-Queue: Victor Porof <victorporof@chromium.org> Reviewed-by: Mathias Bynens <mathias@chromium.org>