Skip to content

Commit

Permalink
Fixed Recentfiles are not saved properly when rebooted
Browse files Browse the repository at this point in the history
  • Loading branch information
EX3exp committed Dec 10, 2024
1 parent 5ca08aa commit 2b94e7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
15 changes: 15 additions & 0 deletions Mirivoice/Mirivoice.Core/Managers/MainManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void Initialize()
UpdateDefaultVoicers();
LoadVoicerManager();
LoadSetting();
LoadRecentFiles();

InitializationTask = Task.Run(() => {
Log.Information("MainManager Initialize Start");
Expand All @@ -74,6 +75,20 @@ public void LoadSetting()
MainManager.Instance.Setting.Save();
}
}

public void LoadRecentFiles()
{
if (File.Exists(MainManager.Instance.PathM.RecentFilesPath))
{
var yamlUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(ReadTxtFile(MainManager.Instance.PathM.RecentFilesPath));
MainManager.Instance.Recent = YamlSerializer.Deserialize<RecentFiles>(yamlUtf8Bytes);
}
else
{
MainManager.Instance.Recent.Save();
}
}

private static void DeleteExtractedZip(string zipFilePath)
{
// deletes zip file and split files
Expand Down
16 changes: 2 additions & 14 deletions Mirivoice/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -913,21 +913,9 @@ public void EndProgress()

public void LoadRecentFIles()
{
if (!File.Exists(MainManager.Instance.PathM.RecentFilesPath))
{
RecentFiles = new RecentFiles();
RecentFiles.Save();
RecentFiles.Validate();
OnPropertyChanged(nameof(RecentMenuCollection));

}
else
{
var yamlUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(MainManager.Instance.ReadTxtFile(MainManager.Instance.PathM.RecentFilesPath));
RecentFiles = YamlSerializer.Deserialize<RecentFiles>(yamlUtf8Bytes);
RecentFiles.Validate();
OnPropertyChanged(nameof(RecentMenuCollection));
}
RecentFiles = MainManager.Instance.Recent;
OnPropertyChanged(nameof(RecentMenuCollection));
RecentFiles.UpdateUI(this); // update UI
}

Expand Down

0 comments on commit 2b94e7c

Please sign in to comment.