I moved some UserDefaults outside of Preferences class because they should be local state of some views instead of global shared state (e.g. filterText, carrier). I used @AppStorage for memory persistence accros launches.
For filterText I made the filterSimulator() func of SimulatorsController public to be able to update the list when filterText changes.
I also removed some useless .environmentObject(preferences) calls since it was already called higher in the view tree.
There are still some UserDefaults that could be removed from Preferences I think.
All those changes avoid lots of .body computations that were uselessly triggered by the many Preferences updates triggered by keystrokes (in URL and Carrier fields for instance) and updating the simulators list view.
Discussion in issue https://github.com/twostraws/ControlRoom/issues/107.
I moved some
UserDefaults
outside ofPreferences
class because they should be local state of some views instead of global shared state (e.g.filterText
,carrier
). I used@AppStorage
for memory persistence accros launches.For
filterText
I made thefilterSimulator()
func ofSimulatorsController
public to be able to update the list whenfilterText
changes.I also removed some useless
.environmentObject(preferences)
calls since it was already called higher in the view tree.There are still some
UserDefaults
that could be removed fromPreferences
I think.All those changes avoid lots of
.body
computations that were uselessly triggered by the manyPreferences
updates triggered by keystrokes (in URL and Carrier fields for instance) and updating the simulators list view.