Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect timestamp and metadata for repeated listens in cache #113

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Jellyfin.Plugin.ListenBrainz/Clients/ListenBrainzClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ private IEnumerable<Listen> ToListens(IEnumerable<StoredListen> storedListens)
if (_libraryManager is null) throw new InvalidOperationException("Library manager is not available");

var listensToConvert = storedListens.ToArray();
return listensToConvert
.Select(l => _libraryManager.GetItemById(l.Id))
.Cast<Audio>()
.Select(a => a.AsListen(
listensToConvert.First(l => l.Id == a.Id).ListenedAt,
listensToConvert.First(l => l.Id == a.Id).Metadata));
return listensToConvert.Select(l =>
{
var baseItem = _libraryManager.GetItemById(l.Id);
var audio = (Audio?)baseItem ?? throw new PluginException("Invalid item");
lyarenei marked this conversation as resolved.
Show resolved Hide resolved
return audio.AsListen(l.ListenedAt, l.Metadata);
});
}

/// <summary>
Expand Down
Loading