1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 15:27:30 +08:00

Update delete collections message when none

This commit is contained in:
Brandon 2024-02-22 19:40:02 -08:00
parent d6beae2ce1
commit 6c8204f9a3
2 changed files with 20 additions and 2 deletions

View File

@ -104,6 +104,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString DeletedAllCollections => new TranslatableString(getKey(@"deleted_all_collections"), @"Deleted all collections!");
/// <summary>
/// "No collections found to delete!"
/// </summary>
public static LocalisableString NoCollectionsFoundToDelete => new TranslatableString(getKey(@"no_collections_found_to_delete"), @"No collections found to delete!");
/// <summary>
/// "Deleted all mod presets!"
/// </summary>

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Game.Collections;
@ -35,8 +36,20 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private void deleteAllCollections()
{
realm.Write(r => r.RemoveAll<BeatmapCollection>());
notificationOverlay?.Post(new ProgressCompletionNotification { Text = MaintenanceSettingsStrings.DeletedAllCollections });
bool anyDeleted = realm.Write(r =>
{
if (r.All<BeatmapCollection>().Any())
{
r.RemoveAll<BeatmapCollection>();
return true;
}
else
{
return false;
}
});
notificationOverlay?.Post(new ProgressCompletionNotification { Text = anyDeleted ? MaintenanceSettingsStrings.DeletedAllCollections : MaintenanceSettingsStrings.NoCollectionsFoundToDelete });
}
}
}