From 1e155af948e652606f9ddf90f8b089315baea809 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 19 Nov 2022 09:31:48 +0100 Subject: [PATCH] Ensured stats for renamed tagged are propagated to new name --- src/tags/reducers/tagsList.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tags/reducers/tagsList.ts b/src/tags/reducers/tagsList.ts index 7914421c..d348674c 100644 --- a/src/tags/reducers/tagsList.ts +++ b/src/tags/reducers/tagsList.ts @@ -116,8 +116,12 @@ export const tagsListReducerCreator = ( tags: rejectTag(tags, tag), filteredTags: rejectTag(filteredTags, tag), })); - builder.addCase(tagEdited, ({ tags, filteredTags, ...rest }, { payload }) => ({ + builder.addCase(tagEdited, ({ tags, filteredTags, stats, ...rest }, { payload }) => ({ ...rest, + stats: { + ...stats, + [payload.newName]: stats[payload.oldName], + }, tags: tags.map(renameTag(payload.oldName, payload.newName)).sort(), filteredTags: filteredTags.map(renameTag(payload.oldName, payload.newName)).sort(), }));