mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Ensure undeleted items are populated with includes before firing events
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
@ -23,7 +22,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="obj">The object to use as a reference when negotiating a local instance.</param>
|
/// <param name="obj">The object to use as a reference when negotiating a local instance.</param>
|
||||||
/// <param name="lookupSource">An optional lookup source which will be used to query and populate a freshly retrieved replacement. If not provided, the refreshed object will still be returned but will not have any includes.</param>
|
/// <param name="lookupSource">An optional lookup source which will be used to query and populate a freshly retrieved replacement. If not provided, the refreshed object will still be returned but will not have any includes.</param>
|
||||||
/// <typeparam name="T">A valid EF-stored type.</typeparam>
|
/// <typeparam name="T">A valid EF-stored type.</typeparam>
|
||||||
protected virtual void Refresh<T>(ref T obj, IEnumerable<T> lookupSource = null) where T : class, IHasPrimaryKey
|
protected virtual void Refresh<T>(ref T obj, IQueryable<T> lookupSource = null) where T : class, IHasPrimaryKey
|
||||||
{
|
{
|
||||||
using (var usage = ContextFactory.GetForWrite())
|
using (var usage = ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,6 @@ namespace osu.Game.Database
|
|||||||
Refresh(ref item);
|
Refresh(ref item);
|
||||||
|
|
||||||
if (item.DeletePending) return false;
|
if (item.DeletePending) return false;
|
||||||
|
|
||||||
item.DeletePending = true;
|
item.DeletePending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +64,9 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
Refresh(ref item);
|
Refresh(ref item, ConsumableItems);
|
||||||
|
|
||||||
if (!item.DeletePending) return false;
|
if (!item.DeletePending) return false;
|
||||||
|
|
||||||
item.DeletePending = false;
|
item.DeletePending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +74,8 @@ namespace osu.Game.Database
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual IQueryable<T> AddIncludesForConsumption(IQueryable<T> query) => query;
|
||||||
|
|
||||||
protected virtual IQueryable<T> AddIncludesForDeletion(IQueryable<T> query) => query;
|
protected virtual IQueryable<T> AddIncludesForDeletion(IQueryable<T> query) => query;
|
||||||
|
|
||||||
protected virtual void Purge(List<T> items, OsuDbContext context)
|
protected virtual void Purge(List<T> items, OsuDbContext context)
|
||||||
|
Reference in New Issue
Block a user