Skip to content

Conversation

gadfly3173
Copy link
Contributor

No description provided.

@love-linger
Copy link
Collaborator

Is there any BUG with preference.json saving?

@gadfly3173
Copy link
Contributor Author

Is there any BUG with preference.json saving?

Now saving will only be triggered when you manually close the app. If you force shutdown when Windows shutdown, software crashes, etc., preference.json will not be saved, which is sometimes a bit confusing.

@gadfly3173
Copy link
Contributor Author

The current PR does not save the configuration when the RepositoryNode changes, which should be safe.

@love-linger
Copy link
Collaborator

You should solve the problem in this way.

  1. Modify App.Initialize() in App.axaml.cs:
    image
  2. Modify Preference.cs in ViewModels by calling Save() in AddNode(...), MoveNode(...), RemoveNode(...) and SortByRenamedNode(...)

@love-linger love-linger self-assigned this Sep 2, 2024
@love-linger love-linger added the enhancement New feature or request label Sep 2, 2024
@love-linger love-linger merged commit 9ee9f92 into sourcegit-scm:develop Sep 2, 2024
13 checks passed
@gadfly3173 gadfly3173 deleted the feat/save-preference branch September 2, 2024 04:11
love-linger added a commit that referenced this pull request Sep 2, 2024
It's ok to call `Save()` multiple times after property of `ViewModels.Preference` changed immediately. If we delay the saving operation 3 seconds after the property changed event, we reduce the times calling `Save`, but the issue metioned in #436 may still exists.
@gadfly3173
Copy link
Contributor Author

The reason for using asynchronous operations when not closing the application is that File.WriteAllText is a synchronous operation. Frequent calls to it to write files may cause lag in some environments. For example, WSL2 file operations are performed over the network, and the IO performance is very low.

9fe8ffc increased the number of saving opertions for the MoveNode method. When called synchronously and without deduplication, the Save method will be called 3 times in RemoveNode, AddNode, and MoveNode method.

@love-linger
Copy link
Collaborator

Yes, I know. As I commented in the commit message, using asynchronous operation will reduce the times calling Save method, but the issue you metioned above still exists since the real saving operation will take place after 3 seconds or even more if there are another change of Preference occurs.

love-linger added a commit that referenced this pull request Sep 2, 2024
love-linger added a commit that referenced this pull request Sep 17, 2024
* remove `string.IsNullOrEmpty(OS.ShellOrTerminal)` checking from detail backend since it has been checked by `Native.OS.OpenTerminal`
* remove `ViewModels.Preference.IsTerminalConfigured` because it is only used by itself (Unlike `IsGitConfigured`).
* add `Native.OS.TestShellOrTerminal` and use it instead of setting `Preference.ShellOrTerminal` directly, because we have binded a callback that will save preference into file when its property changed. It may cause lag in some enviroments if we saving preference into file too frequently (see PR #436).
* run `dotnet format`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants