Skip to content

Commit

Permalink
Tokens are now working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDotH committed Apr 27, 2023
1 parent 60b097d commit 37402fd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,8 @@ public async Task<MusixMatchToken> GetToken()
return null;

MusixMatchToken token = tokens[new Random().Next(0, tokens.Count)];

Core.INSTANCE.SettingsHandler.Settings<TokenSection>()?.RemoveUsage(token);
token.Usage--;

if (token.Usage <= 0)
{
await Core.INSTANCE.SettingsHandler.Settings<TokenSection>()!.RemoveToken(token);
}

return token;
}
}
Expand Down
4 changes: 0 additions & 4 deletions OpenLyricsClient/Backend/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

namespace OpenLyricsClient.Backend
{
// Ideas:
// Textfarbe im fade zum nächsten lyric zeitpunkt ändern,
// also die aktuelle textfarbe ist grün und wird rot, wenn der textabschnitt dran kommt

class Core
{
public static Core INSTANCE;
Expand Down
5 changes: 4 additions & 1 deletion OpenLyricsClient/Backend/Handler/Artwork/ArtworkHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ private async Task ApplyArtworkTask()
Core.INSTANCE.CacheManager.WriteToCache(songRequestObject, artworkCache);
}

if (this._oldArtwork != artworkCache)
if (!DataValidator.ValidateData(artworkCache))
continue;

if (this._oldArtwork == null || this._oldArtwork != artworkCache)
ArtworkFoundEvent(songRequestObject, artworkCache);

this._oldArtwork = artworkCache;
Expand Down
17 changes: 7 additions & 10 deletions OpenLyricsClient/Backend/Settings/Sections/Tokens/TokenSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,21 @@ public async Task RemoveToken(MusixMatchToken token)

public async Task RemoveUsage(MusixMatchToken token)
{
/*List<MusixMatchToken> tokens = GetValue<List<MusixMatchToken>>("Tokens");
List<MusixMatchToken> tokens = GetValue<List<MusixMatchToken>>("Tokens");

for (int i = 0; i < tokens.Capacity; i++)
{
MusixMatchToken currentToken = tokens[i];
if (currentToken.Token.SequenceEqual(token.Token))
{
MusixMatchToken newToken = new MusixMatchToken
{
Token = currentToken.Token,
ExpirationDate = currentToken.ExpirationDate,
Usage = (short)(currentToken.Usage - 1)
};
currentToken.Usage--;

await RemoveToken(token);
await AddToken(newToken);
if (currentToken.Usage <= 0)
tokens.Remove(currentToken);

await SetValue("Tokens", tokens);
}
}*/
}
}

public T GetValue<T>(string field)
Expand Down

0 comments on commit 37402fd

Please sign in to comment.