mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-20 13:27:17 +00:00

Instead of storing the whole selected drive object, we barely store a reference to the corresponding drive in the available drives array (the reference being the drive device). This greatly simplifies the application state in the following ways: - The drive metadata (size, description, etc) is not duplicated in the state, enforcing a single source of truth. - If the selected drive stops being available (e.g: is unplugged), the reference doesn't hold anymore, making this functionality very natural to implement. - Makes `SelectionStateModel.isCurrentDrive()` much more inuitive, since we don't have to document that changes in the metadata of the drive object, or extra keys such as `$$hashKey` don't change the result of this function. - Ensures the state never goes into a problematic state where we try to to write to an unavailable drive. Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>