From ca50dd171bd28b4fcebdc896fc4e86ac6c944b61 Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Wed, 14 Jun 2023 15:57:08 -0700 Subject: [PATCH] [C-2770] Fix issue where playlist library can disappear (#3596) --- .../packages/common/src/store/cache/reducer.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/audius-client/packages/common/src/store/cache/reducer.ts b/apps/audius-client/packages/common/src/store/cache/reducer.ts index 7554b424351..5fb35d5da6e 100644 --- a/apps/audius-client/packages/common/src/store/cache/reducer.ts +++ b/apps/audius-client/packages/common/src/store/cache/reducer.ts @@ -85,8 +85,7 @@ const unwrapEntry = (entry: { metadata: any }) => { const forceUpdateKeys = new Set([ 'field_visibility', 'followee_reposts', - 'followee_saves', - 'playlist_library' + 'followee_saves' ]) // Customize lodash recursive merge to never merge @@ -100,6 +99,12 @@ export const mergeCustomizer = (objValue: any, srcValue: any, key: string) => { return srcValue || objValue } + // Not every user request provides playlist_library, + // so always prefer it's existence, starting with latest + if (key === 'playlist_library') { + return objValue || srcValue + } + // Delete is unidirectional (after marked deleted, future updates are not reflected) if (key === 'is_delete' && objValue === true && srcValue === false) { return objValue