1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:02:55 +08:00

Simplify deletion by adding always present conditionals to Delete method

This commit is contained in:
Dean Herbert 2021-11-29 17:15:48 +09:00
parent f6a3709060
commit 0d18c83d75
2 changed files with 8 additions and 4 deletions

View File

@ -108,7 +108,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
deleteSkinsButton.Enabled.Value = false;
Task.Run(() =>
{
skins.Delete(s => !s.DeletePending);
skins.Delete();
}).ContinueWith(t => Schedule(() => deleteSkinsButton.Enabled.Value = true));
}));
}

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
@ -286,15 +287,18 @@ namespace osu.Game.Skinning
{
using (var context = contextFactory.CreateContext())
{
var items = context.All<SkinInfo>().Where(filter).ToList();
var items = context.All<SkinInfo>()
.Where(s => !s.Protected && !s.DeletePending);
if (filter != null)
items = items.Where(filter);
// check the removed skin is not the current user choice. if it is, switch back to default.
Guid currentUserSkin = CurrentSkinInfo.Value.ID;
if (items.Any(s => s.ID == currentUserSkin))
scheduler.Add(() => CurrentSkinInfo.Value = SkinInfo.Default.ToLive());
scheduler.Add(() => CurrentSkinInfo.Value = Skinning.DefaultSkin.CreateInfo().ToLive());
skinModelManager.Delete(items, silent);
skinModelManager.Delete(items.ToList(), silent);
}
}