diff --git a/OpenLyricsClient/Backend/Collector/Token/Provider/Musixmatch/MusixmatchTokenCollector.cs b/OpenLyricsClient/Backend/Collector/Token/Provider/Musixmatch/MusixmatchTokenCollector.cs index 103f015..18b2221 100644 --- a/OpenLyricsClient/Backend/Collector/Token/Provider/Musixmatch/MusixmatchTokenCollector.cs +++ b/OpenLyricsClient/Backend/Collector/Token/Provider/Musixmatch/MusixmatchTokenCollector.cs @@ -83,15 +83,8 @@ public async Task GetToken() return null; MusixMatchToken token = tokens[new Random().Next(0, tokens.Count)]; - Core.INSTANCE.SettingsHandler.Settings()?.RemoveUsage(token); - token.Usage--; - if (token.Usage <= 0) - { - await Core.INSTANCE.SettingsHandler.Settings()!.RemoveToken(token); - } - return token; } } diff --git a/OpenLyricsClient/Backend/Core.cs b/OpenLyricsClient/Backend/Core.cs index 3aed65b..dc17a7f 100644 --- a/OpenLyricsClient/Backend/Core.cs +++ b/OpenLyricsClient/Backend/Core.cs @@ -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; diff --git a/OpenLyricsClient/Backend/Handler/Artwork/ArtworkHandler.cs b/OpenLyricsClient/Backend/Handler/Artwork/ArtworkHandler.cs index 27a6e6a..d3bc3d1 100644 --- a/OpenLyricsClient/Backend/Handler/Artwork/ArtworkHandler.cs +++ b/OpenLyricsClient/Backend/Handler/Artwork/ArtworkHandler.cs @@ -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; diff --git a/OpenLyricsClient/Backend/Settings/Sections/Tokens/TokenSection.cs b/OpenLyricsClient/Backend/Settings/Sections/Tokens/TokenSection.cs index 0123588..bb0445e 100644 --- a/OpenLyricsClient/Backend/Settings/Sections/Tokens/TokenSection.cs +++ b/OpenLyricsClient/Backend/Settings/Sections/Tokens/TokenSection.cs @@ -67,24 +67,21 @@ public async Task RemoveToken(MusixMatchToken token) public async Task RemoveUsage(MusixMatchToken token) { - /*List tokens = GetValue>("Tokens"); + List tokens = GetValue>("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(string field)