fix: preserve custom canvas skill tags on upgrade
This commit is contained in:
parent
164d9f97e7
commit
02772bc343
@ -224,18 +224,11 @@ export function normalizeCanvasSkillTags(value: unknown): CanvasSkillTag[] {
|
||||
|
||||
function mergeCanvasSkillTagsWithDefaultUpdates(value: unknown): CanvasSkillTag[] {
|
||||
const currentTags = normalizeCanvasSkillTags(value);
|
||||
const currentById = new Map(currentTags.map((tag) => [tag.id, tag]));
|
||||
const defaultIds = new Set(DEFAULT_CANVAS_SKILL_TAGS.map((tag) => tag.id));
|
||||
const merged: CanvasSkillTag[] = DEFAULT_CANVAS_SKILL_TAGS.map((defaultTag) => {
|
||||
const currentTag = currentById.get(defaultTag.id);
|
||||
return currentTag?.iconUrl ? { ...defaultTag, iconUrl: currentTag.iconUrl } : defaultTag;
|
||||
});
|
||||
|
||||
currentTags.forEach((tag) => {
|
||||
if (!defaultIds.has(tag.id)) {
|
||||
merged.push(tag);
|
||||
}
|
||||
});
|
||||
const currentIds = new Set(currentTags.map((tag) => tag.id));
|
||||
const missingDefaultTags = DEFAULT_CANVAS_SKILL_TAGS.filter(
|
||||
(defaultTag) => !currentIds.has(defaultTag.id)
|
||||
);
|
||||
const merged: CanvasSkillTag[] = [...currentTags, ...missingDefaultTags];
|
||||
|
||||
return normalizeCanvasSkillTags(merged);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user