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

feat: move save button components into query renderers #14533

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

mzikherman
Copy link
Contributor

@mzikherman mzikherman commented Sep 20, 2024

This is a bit naive - literally taking all three save button implementations (which are all live / fragment was being requested in our standard Artwork component) - removing their fragments from the parent queries - and replacing the FragmentContainer invocations with QueryRenderers. One actual functionality change which I'll comment on inline.

Nevertheless... it all continues to work! The correct saved state (as well as lot watched count - collector signal which piggybacks onto this saved artwork component - why isn't it is own component? that could be requested + cached up front) 'pops in' momentarily after the main grid query succeeds + renders - it feels totally fine!

General functionality - the save button works when you toggle it on/off, and the toast which includes the 'List' modal popup - also continues to work.

The only personalized snippets remaining in the main filter/grid query:

  • partner offer collector signal - this is N+1 as well
  • 'followed artists' aggregations for the sidebar

@mzikherman mzikherman requested review from damassi and a team September 20, 2024 20:42
@mzikherman mzikherman self-assigned this Sep 20, 2024
@@ -25,7 +23,7 @@ const FlatGridItem: React.FC<FlatGridItemProps> = ({ artwork, onClick }) => {
const { user } = useSystemContext()
const isTeam = userIsTeam(user)
const { containerProps, isSaveButtonVisible } = useSaveButton({
isSaved: !!artwork.isSaved,
isSaved: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was an issue. isSaved was being requested outside of the save button context, and right in this component. It was passed to the useSaveButton hook - which effectively sets isHover: true - thus letting the old-school deprecated button show up always if you've saved the work (even w/o hovering).

With this change, the 'saved' status doesn't show up unless you hover.

Seems relatively minor to me 🙏

Copy link

relativeci bot commented Sep 20, 2024

#427 Bundle Size — 9.55MiB (-0.98%).

0f8bcc4(current) vs 96291e1 main#425(baseline)

Warning

Bundle contains 45 duplicate packages – View duplicate packages

Bundle metrics  Change 4 changes Improvement 1 improvement
                 Current
#427
     Baseline
#425
Improvement  Initial JS 3.95MiB(-0.68%) 3.98MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 47.47% 0%
No change  Chunks 143 143
No change  Assets 146 146
Change  Modules 5637(+0.05%) 5634
No change  Duplicate Modules 455 455
Change  Duplicate Code 5.88%(+0.34%) 5.86%
No change  Packages 291 291
No change  Duplicate Packages 42 42
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#427
     Baseline
#425
Improvement  JS 9.32MiB (-1.05%) 9.42MiB
Regression  Other 237.84KiB (+1.99%) 233.2KiB

Bundle analysis reportBranch saves-list-modal-into-a-rendererProject dashboard


Generated by RelativeCIDocumentationReport issue

@mzikherman mzikherman force-pushed the saves-list-modal-into-a-renderer branch from 043560d to 9d24d12 Compare September 21, 2024 03:30
@@ -167,7 +167,6 @@ const ViewingRoomWorksRouteFixture: ViewingRoomWorksRoute_Test_Query$rawResponse
date: "2015",
additionalInformation: "some description",
href: "/artwork/bill-miles-beep-beep",
artistNames: "Artist Name",
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 sure why the typescript compiler started having issues with all these fields...

@@ -366,17 +366,17 @@ export const Details: React.FC<DetailsProps> = ({

if (!saveOnlyToDefaultList) {
return (
<SaveArtworkToListsButtonFragmentContainer
<SaveArtworkToListsButtonQueryRenderer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main 'type' of change, continue to prop-drill this analytics prop, but instead of passing in the masked fragment via the artwork prop, pass in the artwork id to the query renderer.

@@ -605,8 +605,6 @@ export const DetailsFragmentContainer = createFragmentContainer(Details, {
}
...PrimaryLabelLine_artwork
...BidTimerLine_artwork
...SaveButton_artwork
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is big - removing these fragments from the standard Artwork component query (used in rails + grids).

@mzikherman mzikherman force-pushed the saves-list-modal-into-a-renderer branch from 9d24d12 to a0d0e94 Compare September 21, 2024 03:36
@@ -95,9 +93,9 @@ const FlatGridItem: React.FC<FlatGridItemProps> = ({ artwork, onClick }) => {
)}

{isSaveButtonVisible && (
<DeprecatedSaveButtonFragmentContainer
<DeprecatedSaveButtonQueryRenderer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same thing as above, swapping out fragment container -> query renderer

@@ -133,7 +131,6 @@ export const FlatGridItemFragmentContainer = createFragmentContainer(
@arguments(
includeConsignmentSubmission: $includeConsignmentSubmission
)
...DeprecatedSaveButton_artwork
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the last of these personalized 'save' bits from the overall Artwork query.

}
`}
placeholder={
// TODO: This should be a better placeholder, rather than reusing `SaveButtonBase`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bit of a hack, trying to reuse the main React component (which is typed with Relay data) as the placeholder

return (
<Clickable onClick={() => {}}>
<HeartStrokeIcon fill="white100" width={24} height={24} />
</Clickable>
Copy link
Member

Choose a reason for hiding this comment

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

This makes sense!

damassi
damassi previously approved these changes Sep 23, 2024
Copy link
Member

@damassi damassi left a comment

Choose a reason for hiding this comment

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

👌

@damassi damassi force-pushed the saves-list-modal-into-a-renderer branch from 11f936f to 0f8bcc4 Compare September 23, 2024 17:45
@artsy-peril artsy-peril bot merged commit 955a170 into main Sep 23, 2024
13 checks passed
@artsy-peril artsy-peril bot deleted the saves-list-modal-into-a-renderer branch September 23, 2024 17:59
@artsy-peril artsy-peril bot mentioned this pull request Sep 23, 2024
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.

2 participants