Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue where renaming a tag wouldn't save the new name #14662

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions src/Files.App/Services/Settings/FileTagsSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,19 @@ public void CreateNewTag(string newTagName, string color)

public void EditTag(string uid, string name, string color)
{
var (tag, index) = GetTagAndIndex(uid);
if (tag is null)
var index = GetTagIndex(uid);
if (index == -1)
return;

tag.Name = name;
tag.Color = color;

var oldTags = FileTagList.ToList();
oldTags.RemoveAt(index);
oldTags.Insert(index, tag);
oldTags.Insert(index, new TagViewModel(name, color, uid));
FileTagList = oldTags;
}

public void DeleteTag(string uid)
{
var (_, index) = GetTagAndIndex(uid);
var index = GetTagIndex(uid);
if (index == -1)
return;

Expand Down Expand Up @@ -155,22 +152,15 @@ public override object ExportSettings()
return JsonSettingsSerializer.SerializeToJson(FileTagList);
}

private (TagViewModel?, int) GetTagAndIndex(string uid)
private int GetTagIndex(string uid)
{
TagViewModel? tag = null;
int index = -1;

for (int i = 0; i < FileTagList.Count; i++)
{
if (FileTagList[i].Uid == uid)
{
tag = FileTagList[i];
index = i;
break;
}
return i;
}

return (tag, index);
return -1;
}

private void UntagAllFiles(string uid)
Expand Down
Loading