Skip to content

Conversation

@stanlp1
Copy link
Contributor

@stanlp1 stanlp1 commented Feb 9, 2024

No description provided.

@stanlp1 stanlp1 requested a review from a team February 9, 2024 00:52
if (zeroStateActiveSections && podsData && Object.keys(podsData).length) {
const features = getSearchSuggestionFeatures(Object.values(podsData)[0]);
if (features.featureDisplayZeroStateRecommendations) {
activeSections.length = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too sure I like what I'm doing here.

Copy link

@kwekke kwekke Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there could be side effects when setting activeSections.length = 0 since it modifies the original array. you might want to have immutability for cleaner and predictable code.

consider this scenario

const sections = [a,b,c];
console.log(sections) // prints [a,b,c] 
const {...} = useSections(query, cioClient, sections);
// it runs `activeSections.length = 0`
console.log(sections) /// prints [] 

off the top of my head, you could instead do

const [activeSections, setActiveSections] = useState(zeroStateActiveSections ? zeroStateSections : sections);
useEffect(() => {
  // Delete active sections if feature toggle, zeroStateActiveSessions is present
  if (...) {
    setActiveSections([]);
  }
}, [zeroStateActiveSections, podsData, getSearchSuggestionFeatures])

Copy link
Contributor Author

@stanlp1 stanlp1 Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that definitely conforms to the react pattern better.

Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I left a few comments, let me know what you think

@stanlp1 stanlp1 requested a review from esezen March 8, 2024 07:42
Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think the tests are failing because we have the feature toggle on. Can you turn the toggle of and run tests on the PR before you merge?

@stanlp1 stanlp1 merged commit cdca619 into main Mar 8, 2024
@stanlp1 stanlp1 deleted the csl-3053-os-ui-library-enable-testing-for-zero-state-recommendation branch March 8, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants