Skip to content

Commit

Permalink
Update MainWindow.xaml.cs
Browse files Browse the repository at this point in the history
Fixed saving not working
  • Loading branch information
VespeiProjects authored Sep 30, 2022
1 parent 3b8108e commit 6c563a3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using SharpOSC;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Reflection;

namespace SpotifyOSC_WPF
{
Expand All @@ -23,7 +23,7 @@ public partial class MainWindow : AcrylicWindow
private bool prefixState = true;
private string prefixTxt = "PLAYING:";
private bool completedLoading = false;
private string saveDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
string saveDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
public MainWindow()
{
InitializeComponent();
Expand Down Expand Up @@ -165,6 +165,7 @@ private void loadSettings()
{
File.Create(saveDirectory + "/spotifyOSC/settings.json");
saveSettings();
completedLoading = true;
return;
}
else
Expand All @@ -181,15 +182,13 @@ private void loadSettings()
prefixTxt = newItem.prefixTxtGlobal;
}
completedLoading = true;

}
private void saveSettings()
{
if (completedLoading)
{
Item saveItem = new Item { saveStateGlobal = saveState, typeStateGlobal = typingState, prefixStateGlobal = prefixState, prefixTxtGlobal = prefixTxt };
string rawJson = JsonSerializer.Serialize(saveItem);
Debug.WriteLine(rawJson);
File.WriteAllText(saveDirectory + "/spotifyOSC/settings.json", rawJson);
}
}
Expand Down

0 comments on commit 6c563a3

Please sign in to comment.