From be4496b110e68e2c5a8f76f8ed770e9818befd68 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Tue, 22 Aug 2023 10:00:21 +1000 Subject: Finalised initial implementation of NSFW tag filtering --- HBContext.cs | 4 +- MainLayout.razor | 2 +- Pages/Component/NsfwSwitch.razor | 8 ++++ Pages/Component/Switch.razor | 5 +++ Pages/Component/TagSelectDialog.razor | 18 +++++++- Pages/Gallery.razor | 44 +++++++++++++------ Pages/TagDefinitions.razor | 29 +++++++++---- Pages/Upload.razor | 14 +------ Pages/Upload.razor.css | 9 +++- Program.cs | 1 + Services/TagService.cs | 79 +++++++++++++++++++++++++++++++---- Services/UserStateService.cs | 21 ++++++++++ 12 files changed, 188 insertions(+), 46 deletions(-) create mode 100644 Pages/Component/NsfwSwitch.razor create mode 100644 Services/UserStateService.cs diff --git a/HBContext.cs b/HBContext.cs index 73ccdcb..74c040c 100644 --- a/HBContext.cs +++ b/HBContext.cs @@ -4,7 +4,7 @@ using HyperBooru.Services; namespace HyperBooru; public class HBContext : DbContext { - public static readonly Guid NSFWTag = new("EBDAD4F8-455A-4351-8017-1D4854D6FA38"); + public static readonly Guid NsfwTag = new("EBDAD4F8-455A-4351-8017-1D4854D6FA38"); public static readonly Guid IngestTag = new("EA212801-5BCC-4C0E-814F-FB9D30DB58BC"); public DbSet Objects { get; set; } @@ -40,7 +40,7 @@ public class HBContext : DbContext { modelBuilder.Entity().HasData(new TagDefinition[] { new() { ObjectId = -1, - Guid = NSFWTag, + Guid = NsfwTag, Source = TagSource.Internal, Name = "nsfw" }, diff --git a/MainLayout.razor b/MainLayout.razor index 7720fe2..714c925 100644 --- a/MainLayout.razor +++ b/MainLayout.razor @@ -10,7 +10,7 @@

NSFW

- +
diff --git a/Pages/Component/NsfwSwitch.razor b/Pages/Component/NsfwSwitch.razor new file mode 100644 index 0000000..d4e809b --- /dev/null +++ b/Pages/Component/NsfwSwitch.razor @@ -0,0 +1,8 @@ +@inject IUserStateService userState + + + +@code { + private void ToggleNsfw(bool showNsfw) => + userState.ShowNsfw = showNsfw; +} \ No newline at end of file diff --git a/Pages/Component/Switch.razor b/Pages/Component/Switch.razor index ffb3543..d11ac81 100644 --- a/Pages/Component/Switch.razor +++ b/Pages/Component/Switch.razor @@ -3,6 +3,7 @@