stayintarkov / SIT.Manager.Avalonia

MIT License
38 stars 23 forks source link

There is an issue where saving a profile causes duplicates in ManagerConfig.json #287

Closed stevejackson80 closed 4 months ago

stevejackson80 commented 4 months ago

Duplicate entries end up looking like this (passwords blanked out): Issue

This was caused by CharacterSummaryViewModel having the rememberLogin defaulting to true - if the profile was already saved the login box is not shown and this variable then remains true, which causes the code that checks to see if the connection to EFT was successful and rememberLogin was also true to add the profile to the config. This variable has now been set to false.

Have also added a clean up routine in CharacterSelectionViewModel that removes all duplicate saved profiles (if there are any). It chooses the profile to keep by grouping by username and password, then selecting either the first entry with a ProfileID or the first entry if there are no Profile ID's. All profiles for that username/password are then removed, the profile to be kept placed back into the config and the configuration saved to disk. This method is called when reloading the character list. By adding this clean-up method people will not have to manually remove duplications from their config file - though this part can be removed at a later date.