Fix issue where player names aren't saved

master v3.1
Liza 2024-06-10 19:51:56 +02:00
parent 6763b47509
commit 668287a7e2
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 11 additions and 4 deletions

View File

@ -136,7 +136,7 @@ internal sealed class PersistenceContext
{
try
{
var updates = mappings
var updates = mappings.DistinctBy(x => x.ContentId)
.Where(mapping => mapping.ContentId != 0 && !string.IsNullOrEmpty(mapping.PlayerName))
.Where(mapping =>
{
@ -157,7 +157,13 @@ internal sealed class PersistenceContext
using (var scope = _serviceProvider.CreateScope())
{
using var dbContext = scope.ServiceProvider.GetRequiredService<RetainerTrackContext>();
dbContext.Players.AddRange(updates);
foreach (var update in updates)
{
if (!dbContext.Players.Any(x => x.LocalContentId == update.LocalContentId))
dbContext.Players.AddRange(updates);
}
dbContext.SaveChanges();
}
foreach (var player in updates)

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Version>3.0</Version>
<Version>3.1</Version>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>

View File

@ -37,7 +37,8 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
ServiceCollection serviceCollection = new();
serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)
.ClearProviders()
.AddDalamudLogger(pluginLog));
.AddDalamudLogger(pluginLog)
.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning));
serviceCollection.AddSingleton<IDalamudPlugin>(this);
serviceCollection.AddSingleton(pluginInterface);
serviceCollection.AddSingleton(framework);