Skip to content

Commit

Permalink
Fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDotH committed Apr 27, 2023
1 parent 783a991 commit 9423256
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 9 deletions.
1 change: 1 addition & 0 deletions OpenLyricsClient/Backend/Settings/ISettingSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public interface ISettingSection
T GetValue<T>(string field);
Task SetValue<T>(string field, T value);
JObject Defaults();
string[] GetFields();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using DevBase.Api.Apis.OpenLyricsClient.Structure.Json;
using DevBase.Generics;
using Newtonsoft.Json.Linq;
using OpenLyricsClient.Backend;
using OpenLyricsClient.Backend.Settings;
Expand Down Expand Up @@ -76,4 +78,14 @@ public JObject Defaults()

return new JsonDeserializer().Serialize(structure);
}

public string[] GetFields()
{
AList<string> fields = new AList<string>();

foreach (var pair in this._data)
fields.Add(pair.Key);

return fields.GetAsArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using DevBase.Generics;
using Newtonsoft.Json.Linq;
using OpenLyricsClient.Backend.Structure;
using OpenLyricsClient.Backend.Structure.Enum;
Expand Down Expand Up @@ -96,4 +97,14 @@ public JObject Defaults()

return new JsonDeserializer().Serialize(spotifyAccess);
}

public string[] GetFields()
{
AList<string> fields = new AList<string>();

foreach (var pair in this._data)
fields.Add(pair.Key);

return fields.GetAsArray();
}
}
10 changes: 10 additions & 0 deletions OpenLyricsClient/Backend/Settings/Sections/Lyrics/LyricsSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ public JObject Defaults()

return new JsonDeserializer().Serialize(structure);
}

public string[] GetFields()
{
AList<string> fields = new AList<string>();

foreach (var pair in this._data)
fields.Add(pair.Key);

return fields.GetAsArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ public JObject Defaults()

return new JsonDeserializer().Serialize(structure);
}

public string[] GetFields()
{
AList<string> fields = new AList<string>();

foreach (var pair in this._data)
fields.Add(pair.Key);

return fields.GetAsArray();
}
}
10 changes: 10 additions & 0 deletions OpenLyricsClient/Backend/Settings/Sections/Tokens/TokenSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,14 @@ public JObject Defaults()

return new JsonDeserializer().Serialize(structure);
}

public string[] GetFields()
{
AList<string> fields = new AList<string>();

foreach (var pair in this._data)
fields.Add(pair.Key);

return fields.GetAsArray();
}
}
17 changes: 8 additions & 9 deletions OpenLyricsClient/Backend/Settings/SettingsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ public async Task TriggerEvent<T>(T section, string field)

public async Task TriggerGlobal()
{
this._sections.ForEach(s =>
for (int i = 0; i < this._sections.Length; i++)
{
using (var enumerator = s.Defaults().GetEnumerator())
{
while (enumerator.MoveNext())
{
TriggerEvent(s, enumerator.Current.Key.ToString());
}
}
});
ISettingSection section = this._sections.Get(i);

string[] fields = section.GetFields();

for (int j = 0; j < fields.Length; j++)
await TriggerEvent(section, fields[j]);
}
}
}

0 comments on commit 9423256

Please sign in to comment.