Skip to content

Commit 6c9afe2

Browse files
Fix: Fixed issue where renaming a tag wouldn't save the new name (#14662)
Co-authored-by: hishitetsu <[email protected]>
1 parent db1afa9 commit 6c9afe2

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/Files.App/Services/Settings/FileTagsSettingsService.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,19 @@ public void CreateNewTag(string newTagName, string color)
101101

102102
public void EditTag(string uid, string name, string color)
103103
{
104-
var (tag, index) = GetTagAndIndex(uid);
105-
if (tag is null)
104+
var index = GetTagIndex(uid);
105+
if (index == -1)
106106
return;
107107

108-
tag.Name = name;
109-
tag.Color = color;
110-
111108
var oldTags = FileTagList.ToList();
112109
oldTags.RemoveAt(index);
113-
oldTags.Insert(index, tag);
110+
oldTags.Insert(index, new TagViewModel(name, color, uid));
114111
FileTagList = oldTags;
115112
}
116113

117114
public void DeleteTag(string uid)
118115
{
119-
var (_, index) = GetTagAndIndex(uid);
116+
var index = GetTagIndex(uid);
120117
if (index == -1)
121118
return;
122119

@@ -155,22 +152,15 @@ public override object ExportSettings()
155152
return JsonSettingsSerializer.SerializeToJson(FileTagList);
156153
}
157154

158-
private (TagViewModel?, int) GetTagAndIndex(string uid)
155+
private int GetTagIndex(string uid)
159156
{
160-
TagViewModel? tag = null;
161-
int index = -1;
162-
163157
for (int i = 0; i < FileTagList.Count; i++)
164158
{
165159
if (FileTagList[i].Uid == uid)
166-
{
167-
tag = FileTagList[i];
168-
index = i;
169-
break;
170-
}
160+
return i;
171161
}
172162

173-
return (tag, index);
163+
return -1;
174164
}
175165

176166
private void UntagAllFiles(string uid)

0 commit comments

Comments
 (0)