Skip to content

Commit

Permalink
misc: remove the remaining of the sort name setter
Browse files Browse the repository at this point in the history
- Add back the sort name to the v3 group model, this time read-only.

- Remove the sort name from the v3 create/modify group body,
  since it can no longer be edited by the user.
  • Loading branch information
revam committed Oct 17, 2023
1 parent 845f986 commit 45d83ed
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions Shoko.Server/API/v3/Models/Shoko/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Group : BaseModel
public GroupIDs IDs { get; set; }

/// <summary>
/// The sort name for the group.
/// The sort name for the group. Cannot directly be set by the user.
/// </summary>
public string SortName { get; set; }

Expand Down Expand Up @@ -91,6 +91,7 @@ public Group(HttpContext ctx, SVR_AnimeGroup group, bool randomiseImages = false
IDs.TopLevelGroup = group.TopLevelAnimeGroup.AnimeGroupID;

Name = group.GroupName;
SortName = group.GetSortName();
Description = group.Description;
Sizes = ModelHelper.GenerateGroupSizes(allSeries, episodes, subGroupCount, userID);
Size = allSeries.Count(series => series.AnimeGroupID == group.AnimeGroupID);
Expand Down Expand Up @@ -178,16 +179,6 @@ public class CreateOrUpdateGroupBody
/// </remarks>
public string? Name { get; set; } = null;

/// <summary>
/// The group's custom sort name.
/// </summary>
/// <remarks>
/// The sort name will only be modified if either
/// <see cref="Group.HasCustomName"/> or <see cref="HasCustomName"/>
/// is set to true, and the value is not set to <c>null</c>.
/// </remarks>
public string? SortName { get; set; } = null;

/// <summary>
/// The group's custom description.
/// </summary>
Expand All @@ -203,7 +194,7 @@ public class CreateOrUpdateGroupBody
/// </summary>
/// <remarks>
/// Leave it as <c>null</c> to conditionally set the value if
/// <see cref="Name"/> or <see cref="SortName"/> is set, or
/// <see cref="Name"/> is set, or
/// explictly set it to <c>true</c> to lock in the new/current
/// names, or set it to <c>false</c> to reset the names back to the
/// automatic naming based on the main series.
Expand Down Expand Up @@ -322,7 +313,7 @@ public CreateOrUpdateGroupBody(SVR_AnimeGroup group)
if (HasCustomName.HasValue)
group.IsManuallyNamed = 1;

// The group name and/or the group sort name changed.
// The group name changed.
var overrideName = !string.IsNullOrWhiteSpace(Name) && !string.Equals(group.GroupName, Name);
if (overrideName)
{
Expand Down

0 comments on commit 45d83ed

Please sign in to comment.