mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 12:32:58 +08:00
Ensure undeleted items are populated with includes before firing events
This commit is contained in:
parent
e51450a064
commit
671475f3b4
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
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="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>
|
||||
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())
|
||||
{
|
||||
|
@ -53,7 +53,6 @@ namespace osu.Game.Database
|
||||
Refresh(ref item);
|
||||
|
||||
if (item.DeletePending) return false;
|
||||
|
||||
item.DeletePending = true;
|
||||
}
|
||||
|
||||
@ -65,10 +64,9 @@ namespace osu.Game.Database
|
||||
{
|
||||
using (ContextFactory.GetForWrite())
|
||||
{
|
||||
Refresh(ref item);
|
||||
Refresh(ref item, ConsumableItems);
|
||||
|
||||
if (!item.DeletePending) return false;
|
||||
|
||||
item.DeletePending = false;
|
||||
}
|
||||
|
||||
@ -76,6 +74,8 @@ namespace osu.Game.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual IQueryable<T> AddIncludesForConsumption(IQueryable<T> query) => query;
|
||||
|
||||
protected virtual IQueryable<T> AddIncludesForDeletion(IQueryable<T> query) => query;
|
||||
|
||||
protected virtual void Purge(List<T> items, OsuDbContext context)
|
||||
|
Loading…
Reference in New Issue
Block a user