diff --git a/ui/component/claimMenuList/index.js b/ui/component/claimMenuList/index.js index 468a37254..f42ae0acc 100644 --- a/ui/component/claimMenuList/index.js +++ b/ui/component/claimMenuList/index.js @@ -75,6 +75,10 @@ const select = (state, props) => { lastUsedCollection, hasClaimInLastUsedCollection: lastUsedCollection && makeSelectCollectionForIdHasClaimUrl(lastUsedCollection.id, contentPermanentUri)(state), + lastUsedCollectionIsNotBuiltin: + lastUsedCollection && + lastUsedCollection.id !== COLLECTIONS_CONSTS.WATCH_LATER_ID && + lastUsedCollection.id !== COLLECTIONS_CONSTS.FAVORITES_ID, }; }; diff --git a/ui/component/claimMenuList/view.jsx b/ui/component/claimMenuList/view.jsx index 8656d6efb..e128c1303 100644 --- a/ui/component/claimMenuList/view.jsx +++ b/ui/component/claimMenuList/view.jsx @@ -62,6 +62,7 @@ type Props = { doToggleShuffleList: (string) => void, lastUsedCollection: ?Collection, hasClaimInLastUsedCollection: boolean, + lastUsedCollectionIsNotBuiltin: boolean, }; function ClaimMenuList(props: Props) { @@ -104,6 +105,7 @@ function ClaimMenuList(props: Props) { doToggleShuffleList, lastUsedCollection, hasClaimInLastUsedCollection, + lastUsedCollectionIsNotBuiltin, } = props; const [doShuffle, setDoShuffle] = React.useState(false); const incognitoClaim = contentChannelUri && !contentChannelUri.includes('@'); @@ -363,7 +365,7 @@ function ClaimMenuList(props: Props) { {__('Add to Lists')} - {lastUsedCollection && ( + {lastUsedCollection && lastUsedCollectionIsNotBuiltin && ( diff --git a/ui/redux/reducers/collections.js b/ui/redux/reducers/collections.js index 897771e35..04dd391ea 100644 --- a/ui/redux/reducers/collections.js +++ b/ui/redux/reducers/collections.js @@ -181,7 +181,7 @@ const collectionsReducer = handleActions( }, [ACTIONS.COLLECTION_ITEMS_RESOLVE_COMPLETED]: (state, action) => { const { resolvedCollections, failedCollectionIds } = action.data; - const { pending, edited, isResolvingCollectionById, resolved } = state; + const { pending, edited, isResolvingCollectionById, resolved, lastUsedCollection } = state; const newPending = Object.assign({}, pending); const newEdited = Object.assign({}, edited); const newResolved = Object.assign({}, resolved, resolvedCollections); @@ -208,12 +208,31 @@ const collectionsReducer = handleActions( }); } + const newAllCollections = [ + ...Object.values(newPending), + ...Object.values(newResolved), + ...Object.values(newEdited), + ]; + + let newLastUsedCollection = lastUsedCollection; + + // If a collection is being published or got published, + // its id will get updated which means, we have to sync + // the last used collection. + if (lastUsedCollection) { + newLastUsedCollection = newAllCollections.find((collection) => { + // $FlowFixMe + return collection.name === lastUsedCollection.name; + }); + } + return Object.assign({}, state, { ...state, pending: newPending, resolved: newResolved, edited: newEdited, isResolvingCollectionById: newResolving, + lastUsedCollection: newLastUsedCollection, }); }, [ACTIONS.COLLECTION_ITEMS_RESOLVE_FAILED]: (state, action) => {