Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: address new works for you comments #9935

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MounirDhahri
Copy link
Member

@MounirDhahri MounirDhahri commented Mar 5, 2024

This PR resolves ONYX-840

Description

The goal from this PR is addressing the design comments on the New Works For You screen raised by Barney and removing the old logic.

  • Make New works for you header animation more smooth and make sure the artworks count doesn't disappear.
  • Make it possible to QA this using the dev menu
  • Release the feature to all users and remove the experiment related code

Before

Screen.Recording.2024-03-06.at.12.11.59.mov

After

Screen.Recording.2024-03-12.at.17.04.53.mov

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

iOS user-facing changes

Android user-facing changes

Dev changes

Need help with something? Have a look at our docs, or get in touch with us.

@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented Mar 5, 2024

Warnings
⚠️

An error occurred while validating your changelog, please make sure you provided a valid changelog.

Generated by 🚫 dangerJS against 99bc49e

@MounirDhahri MounirDhahri changed the title chore: address review comments chore: address new works for you comments Mar 6, 2024
@MounirDhahri MounirDhahri self-assigned this Mar 6, 2024
@MounirDhahri MounirDhahri force-pushed the fix/show-the-right-version branch 2 times, most recently from c7c32b9 to 5506987 Compare March 11, 2024 14:50
@MounirDhahri MounirDhahri marked this pull request as ready for review March 12, 2024 15:49
Copy link
Contributor

@olerichter00 olerichter00 left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes! I've added some ideas about simplifying the hacky part :)

Comment on lines +29 to +52
const [hasChangedLayout, setHasChangedLayout] = useState(false)

const firstUpdate = useRef(true)

// This is a hack to force the grid to re-render when the layout changes
// Flashlist makes a werid animation when changing between numColumns
// We avoid it by showing the placeholder for a second while it's happening
useLayoutEffect(() => {
if (firstUpdate.current) {
firstUpdate.current = false
return
}

setHasChangedLayout(true)
}, [numColumns])

if (hasChangedLayout) {
setTimeout(() => {
setHasChangedLayout(false)
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
}, 1000)

return <NewWorksForYouPlaceholder />
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about moving this logic into MasonryInfiniteScrollArtworkGrid and converting it into a hook to avoid duplication? I guess, this issue will arise wherever i't possible to change the number of columns.

const artworks = extractNodes(data.artworks)
const numColumns = defaultViewOption === "grid" ? NUM_COLUMNS_MASONRY : 1

const [hasChangedLayout, setHasChangedLayout] = useState(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using/overriding a layout animation here, could we simply show the placeholder between the column change? I'm thinking of something like this inside of MasonryInfiniteScrollArtworkGrid:

const [internalNumColumns, setInternalNumColumns] = useState(numColumns)
const [showPlaceholder, setShowPlaceholder] = useState(false)

useEffect(() => {
  showPlaceholder(true)
}, [numColumns])

useEffect(() => {
  if (!showPlaceholder) return
  
  setInternalNumColumns(numColumns)
  showPlaceholder(false)
}, [showPlaceholder])

Comment on lines +72 to +78
useEffect(() => {
if (hideTitle) {
if (currentScrollY >= NAVBAR_HEIGHT) {
setHideTitle(false)
}
}
}, [currentScrollY])
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants