Made tags an array of integers instead of strings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
namespace LightlessSync.Services;
|
||||
|
||||
public record LightlessGroupProfileData(string Base64ProfilePicture, string Description, string Tags, bool IsNsfw, bool IsDisabled)
|
||||
public record LightlessGroupProfileData(string Base64ProfilePicture, string Description, int[] Tags, bool IsNsfw, bool IsDisabled)
|
||||
{
|
||||
public Lazy<byte[]> ImageData { get; } = new Lazy<byte[]>(Convert.FromBase64String(Base64ProfilePicture));
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ public class LightlessProfileManager : MediatorSubscriberBase
|
||||
|
||||
private readonly LightlessUserProfileData _defaultProfileUserData = new(IsFlagged: false, IsNSFW: false, _lightlessLogo, string.Empty, _noUserDescription);
|
||||
private readonly LightlessUserProfileData _loadingProfileUserData = new(IsFlagged: false, IsNSFW: false, _lightlessLogoLoading, string.Empty, _loadingData);
|
||||
private readonly LightlessGroupProfileData _loadingProfileGroupData = new(_lightlessLogoLoading, _loadingData, string.Empty, IsNsfw: false, IsDisabled: false);
|
||||
private readonly LightlessGroupProfileData _defaultProfileGroupData = new(_lightlessLogo, _noGroupDescription, string.Empty, IsNsfw: false, IsDisabled: false);
|
||||
private readonly LightlessGroupProfileData _loadingProfileGroupData = new(_lightlessLogoLoading, _loadingData, [], IsNsfw: false, IsDisabled: false);
|
||||
private readonly LightlessGroupProfileData _defaultProfileGroupData = new(_lightlessLogo, _noGroupDescription, [], IsNsfw: false, IsDisabled: false);
|
||||
private readonly LightlessUserProfileData _nsfwProfileUserData = new(IsFlagged: false, IsNSFW: true, _lightlessLogoNsfw, string.Empty, _nsfwDescription);
|
||||
private readonly LightlessGroupProfileData _nsfwProfileGroupData = new(_lightlessLogoNsfw, _nsfwDescription, string.Empty, IsNsfw: false, IsDisabled: false);
|
||||
private readonly LightlessGroupProfileData _nsfwProfileGroupData = new(_lightlessLogoNsfw, _nsfwDescription, [], IsNsfw: false, IsDisabled: false);
|
||||
|
||||
public LightlessProfileManager(ILogger<LightlessProfileManager> logger, LightlessConfigService lightlessConfigService,
|
||||
LightlessMediator mediator, ApiController apiController) : base(logger, mediator)
|
||||
@@ -162,10 +162,13 @@ public class LightlessProfileManager : MediatorSubscriberBase
|
||||
_lightlessGroupProfiles[data] = _loadingProfileGroupData;
|
||||
var profile = await _apiController.GroupGetProfile(new API.Dto.Group.GroupDto(data)).ConfigureAwait(false);
|
||||
|
||||
LightlessGroupProfileData profileGroupData = new(Base64ProfilePicture: string.IsNullOrEmpty(profile.PictureBase64) ? _lightlessLogo : profile.PictureBase64,
|
||||
LightlessGroupProfileData profileGroupData = new(
|
||||
Base64ProfilePicture: string.IsNullOrEmpty(profile.PictureBase64) ? _lightlessLogo : profile.PictureBase64,
|
||||
Description: string.IsNullOrEmpty(profile.Description) ? _noGroupDescription : profile.Description,
|
||||
Tags: string.IsNullOrEmpty(profile.Tags) ? string.Empty : profile.Tags,
|
||||
profile.IsNsfw ?? false, profile.IsDisabled ?? false);
|
||||
Tags: profile.Tags ?? [],
|
||||
profile.IsNsfw ?? false,
|
||||
profile.IsDisabled ?? false
|
||||
);
|
||||
|
||||
_logger.LogTrace("Replacing data in _lightlessGroupProfiles for Group {data}", data.AliasOrGID);
|
||||
if (profileGroupData.IsNsfw && !_lightlessConfigService.Current.ProfilesAllowNsfw)
|
||||
|
||||
@@ -110,7 +110,6 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
|
||||
? Convert.FromBase64String(_lightlessLogo)
|
||||
: Convert.FromBase64String(_groupProfile.PictureBase64);
|
||||
string? profileDescription = string.IsNullOrEmpty(_groupProfile.Description) ? _defaultDescription : _groupProfile.Description;
|
||||
string? profileTags = string.IsNullOrEmpty(_groupProfile.Description) ? _defaultTags : _groupProfile.Tags;
|
||||
|
||||
_pfpTextureWrap?.Dispose();
|
||||
_pfpTextureWrap = _uiSharedService.LoadImage(profilePicture);
|
||||
|
||||
12
LightlessSync/UI/ProfileTags.cs
Normal file
12
LightlessSync/UI/ProfileTags.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace LightlessSync.UI
|
||||
{
|
||||
public enum ProfileTags
|
||||
{
|
||||
SFW = 0,
|
||||
NSFW = 1,
|
||||
RP = 2,
|
||||
ERP = 3,
|
||||
Venues = 4,
|
||||
Gpose = 5
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
private Task<int>? _pruneTestTask;
|
||||
private Task<int>? _pruneTask;
|
||||
private int _pruneDays = 14;
|
||||
private readonly List<string> _allowedTags = ["SFW", "NSFW", "RP", "ERP", "Venues", "Gpose"];
|
||||
private List<string> _selectedTags = [];
|
||||
private List<int> _selectedTags = [];
|
||||
|
||||
public SyncshellAdminUI(ILogger<SyncshellAdminUI> logger, LightlessMediator mediator, ApiController apiController,
|
||||
UiSharedService uiSharedService, PairManager pairManager, GroupFullInfoDto groupFullInfo, PerformanceCollectorService performanceCollectorService, LightlessProfileManager lightlessProfileManager, FileDialogManager fileDialogManager)
|
||||
@@ -321,7 +320,11 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
ImGui.TextUnformatted($"Tags:");
|
||||
var childFrameLocal = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 200);
|
||||
|
||||
foreach (string tag in _allowedTags)
|
||||
var allCategoryIndexes = Enum.GetValues<ProfileTags>()
|
||||
.Cast<int>()
|
||||
.ToList();
|
||||
|
||||
foreach(int tag in allCategoryIndexes)
|
||||
{
|
||||
using (ImRaii.PushId($"tag-{tag}")) DrawTag(tag);
|
||||
}
|
||||
@@ -727,20 +730,22 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
inviteTab.Dispose();
|
||||
}
|
||||
private void DrawTag(string tag)
|
||||
private void DrawTag(int tag)
|
||||
{
|
||||
var HasTag = _selectedTags.Contains(tag, StringComparer.Ordinal);
|
||||
if (ImGui.Checkbox(tag, ref HasTag))
|
||||
var HasTag = _selectedTags.Contains(tag);
|
||||
var tagName = (ProfileTags)tag;
|
||||
|
||||
if (ImGui.Checkbox(tagName.ToString(), ref HasTag))
|
||||
{
|
||||
if (HasTag)
|
||||
{
|
||||
_selectedTags.Add(tag);
|
||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null, IsNsfw: null, IsDisabled: null));
|
||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: _selectedTags.ToArray(), PictureBase64: null, IsNsfw: null, IsDisabled: null));
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedTags.Remove(tag);
|
||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null, IsNsfw: null, IsDisabled: null));
|
||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: _selectedTags.ToArray(), PictureBase64: null, IsNsfw: null, IsDisabled: null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -749,26 +754,10 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
{
|
||||
if (_profileData != null)
|
||||
{
|
||||
_selectedTags = StringToList(_profileData.Tags, ",");
|
||||
_selectedTags = [.. _profileData.Tags];
|
||||
}
|
||||
}
|
||||
|
||||
private static string ListToString(List<string> list, string delimiter)
|
||||
{
|
||||
if (list == null || list.Count == 0)
|
||||
return string.Empty;
|
||||
|
||||
return string.Join(delimiter, list);
|
||||
}
|
||||
|
||||
public static List<string> StringToList(string input, string delimiter)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
return [];
|
||||
|
||||
return [.. input.Split([delimiter], StringSplitOptions.None)];
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
Mediator.Publish(new RemoveWindowMessage(this));
|
||||
|
||||
Reference in New Issue
Block a user