1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

Move and adjust implementation regions to restore sanity

This commit is contained in:
Dean Herbert 2022-06-16 18:26:13 +09:00
parent 4d9e3d1982
commit 04e4c5ef88

View File

@ -260,8 +260,6 @@ namespace osu.Game.Beatmaps
return realm.Run(r => r.All<BeatmapSetInfo>().FirstOrDefault(query)?.ToLive(realm)); return realm.Run(r => r.All<BeatmapSetInfo>().FirstOrDefault(query)?.ToLive(realm));
} }
#region Delegation to BeatmapImporter (methods which previously existed locally).
/// <summary> /// <summary>
/// Perform a lookup query on available <see cref="BeatmapInfo"/>s. /// Perform a lookup query on available <see cref="BeatmapInfo"/>s.
/// </summary> /// </summary>
@ -283,38 +281,6 @@ namespace osu.Game.Beatmaps
set => beatmapImporter.PostNotification = value; set => beatmapImporter.PostNotification = value;
} }
#endregion
#region Implementation of IModelManager<BeatmapSetInfo>
public bool IsAvailableLocally(BeatmapSetInfo model)
{
return beatmapImporter.IsAvailableLocally(model);
}
public bool Delete(BeatmapSetInfo item)
{
return beatmapImporter.Delete(item);
}
public void Delete(List<BeatmapSetInfo> items, bool silent = false)
{
beatmapImporter.Delete(items, silent);
}
public void Delete(Expression<Func<BeatmapSetInfo, bool>>? filter = null, bool silent = false)
{
realm.Run(r =>
{
var items = r.All<BeatmapSetInfo>().Where(s => !s.DeletePending && !s.Protected);
if (filter != null)
items = items.Where(filter);
beatmapImporter.Delete(items.ToList(), silent);
});
}
/// <summary> /// <summary>
/// Saves an <see cref="IBeatmap"/> file against a given <see cref="BeatmapInfo"/>. /// Saves an <see cref="IBeatmap"/> file against a given <see cref="BeatmapInfo"/>.
/// </summary> /// </summary>
@ -381,6 +347,19 @@ namespace osu.Game.Beatmaps
}); });
} }
public void Delete(Expression<Func<BeatmapSetInfo, bool>>? filter = null, bool silent = false)
{
realm.Run(r =>
{
var items = r.All<BeatmapSetInfo>().Where(s => !s.DeletePending && !s.Protected);
if (filter != null)
items = items.Where(filter);
beatmapImporter.Delete(items.ToList(), silent);
});
}
/// <summary> /// <summary>
/// Delete videos from a list of beatmaps. /// Delete videos from a list of beatmaps.
/// This will post notifications tracking progress. /// This will post notifications tracking progress.
@ -431,15 +410,17 @@ namespace osu.Game.Beatmaps
realm.Run(r => beatmapImporter.Undelete(r.All<BeatmapSetInfo>().Where(s => s.DeletePending).ToList())); realm.Run(r => beatmapImporter.Undelete(r.All<BeatmapSetInfo>().Where(s => s.DeletePending).ToList()));
} }
public void Undelete(List<BeatmapSetInfo> items, bool silent = false) #region Implementation of IModelManager<BeatmapSetInfo>
{
beatmapImporter.Undelete(items, silent);
}
public void Undelete(BeatmapSetInfo item) public bool IsAvailableLocally(BeatmapSetInfo model) => beatmapImporter.IsAvailableLocally(model);
{
beatmapImporter.Undelete(item); public bool Delete(BeatmapSetInfo item) => beatmapImporter.Delete(item);
}
public void Delete(List<BeatmapSetInfo> items, bool silent = false) => beatmapImporter.Delete(items, silent);
public void Undelete(List<BeatmapSetInfo> items, bool silent = false) => beatmapImporter.Undelete(items, silent);
public void Undelete(BeatmapSetInfo item) => beatmapImporter.Undelete(item);
#endregion #endregion