From abe500bdb2cee643a593fe11286be383bd481af9 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Sat, 30 May 2026 04:00:45 +1000 Subject: Added tag source to API tag model --- HBContext.cs | 3 ++- Pages/Component/MediaTagTable.razor | 2 +- Pages/Component/TagSelectDialog.razor | 2 +- Pages/TagDefinitions.razor | 4 ++-- Tag.cs | 9 +++------ 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/HBContext.cs b/HBContext.cs index b684a51..766c0a3 100644 --- a/HBContext.cs +++ b/HBContext.cs @@ -1,4 +1,5 @@ -using HyperBooru.Services; +using HyperBooru.ApiModels; +using HyperBooru.Services; using Microsoft.EntityFrameworkCore; namespace HyperBooru; diff --git a/Pages/Component/MediaTagTable.razor b/Pages/Component/MediaTagTable.razor index e687529..1b62832 100644 --- a/Pages/Component/MediaTagTable.razor +++ b/Pages/Component/MediaTagTable.razor @@ -61,7 +61,7 @@ var media = db.Media.First(m => m.ObjectId == Media.ObjectId); tagDefs = tagService.GetAllTags(Media) - .Where(e => e.tagDefinition.Source == TagSource.UserTag) + .Where(e => e.tagDefinition.Source == ApiModels.TagSource.UserTag) .ToArray(); } diff --git a/Pages/Component/TagSelectDialog.razor b/Pages/Component/TagSelectDialog.razor index 87065d7..d33b178 100644 --- a/Pages/Component/TagSelectDialog.razor +++ b/Pages/Component/TagSelectDialog.razor @@ -97,7 +97,7 @@ tagDefinitions = db.TagDefinitions .Include(td => td.ImplicitTags) - .Where(td => td.Source == TagSource.UserTag) + .Where(td => td.Source == ApiModels.TagSource.UserTag) .OrderBy(td => td.Name) .AsEnumerable() .Where(td => userService.UserSessionState.ShowNsfw || !td.ImplicitTags diff --git a/Pages/TagDefinitions.razor b/Pages/TagDefinitions.razor index f3dca0f..c67a43f 100644 --- a/Pages/TagDefinitions.razor +++ b/Pages/TagDefinitions.razor @@ -34,7 +34,7 @@ @{ var implicitTags = tagDef.ImplicitTags - .Where(td => td.Source == TagSource.UserTag); + .Where(td => td.Source == ApiModels.TagSource.UserTag); foreach(var tag in implicitTags) { @tag.Name @@ -108,7 +108,7 @@ tagDefinitions = dbFactory.CreateDbContext().TagDefinitions .Include(td => td.ImplicitTags) - .Where(td => td.Source == TagSource.UserTag) + .Where(td => td.Source == ApiModels.TagSource.UserTag) .OrderBy(td => td.Namespace) .ThenBy(td => td.Name) .AsEnumerable() diff --git a/Tag.cs b/Tag.cs index c857c66..7da6232 100644 --- a/Tag.cs +++ b/Tag.cs @@ -1,12 +1,8 @@ -using System.ComponentModel.DataAnnotations.Schema; +using HyperBooru.ApiModels; +using System.ComponentModel.DataAnnotations.Schema; namespace HyperBooru; -public enum TagSource { - Internal, - UserTag -} - public class TagDefinition : HBObject { public TagSource Source { get; set; } = TagSource.Internal; public string? Namespace { get; set; } @@ -16,6 +12,7 @@ public class TagDefinition : HBObject { public static explicit operator ApiModels.TagDefinition(TagDefinition tagDefinition) => new() { TagDefinitionId = tagDefinition.Guid, + Source = tagDefinition.Source, Namespace = tagDefinition.Namespace, Name = tagDefinition.Name, Alias = tagDefinition.Alias, -- cgit v1.3