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

Details redesign tweaks and refactoring #3995

Merged

Conversation

DingDongSoLong4
Copy link
Collaborator

@DingDongSoLong4 DingDongSoLong4 commented Aug 2, 2023

These are a few tweaks and changes related to the recent details redesign, with some refactoring thrown in as well.

  • The state flag for the sticky header is now initialized to the correct value rather than waiting for an onscroll event. This fixes an issue I came across where the sticky header would flicker if the page's initial scroll position was such that the header should show.
  • The intl ID for the StashID detail item label was incorrect, leading to a console error and the ID being directly displayed (ie without being translated). I've fixed this and also added i18n for a few other hardcoded "StashIDs" labels. This does bring up the question on whether it's "Stash IDs" or "StashIDs" - the en-GB.json translation file has "Stash IDs" but the hardcoded strings all were "StashIDs". All the labels are now consistently display "Stash IDs", but I feel like "StashIDs" looks better - although maybe that's simply because I've seen "StashIDs" more often.
  • The main details redesign-related fix is removing the window.scrollTo(0, 0) in the GridCard onclick event and instead scrolling up to the top when a "long" component (studios, tags, etc pages, list pages) is mounted. The scrollTo in the onclick was causing the page to unconditionally scroll up when clicking on a card, even if the click doesn't actually navigate away to a new page (eg a middle click to open in a new tab).
  • Added an id to the cover field of SlimGalleryData, thus allowing the field to be properly cached, which fixes a console warning complaining about the missing ID. I also set the merge function for the paths field of a Scene object to false, fixing another console warning, and removed a few unnecessary false merge functions on fields which return normalized objects and thus do not need them.
  • Refactored the ugly page title string templating code out into useTitleProps and makeTitleProps, and made it more modular with support for multiple pipe-separated parts.
  • Refactored the various loaders (SceneLoader, PerformerLoader, etc) and created an ImageLoader to directly use the RouteComponentProps passed to them by react-router instead of useLocation or useParams.
  • Refactored the handling of the "tab" URL parameter, adding a TabKey type. Now instead of having /performer/11 display the performer's scenes, the page will be redirected to /performer/11/scenes first before showing the scenes. This allows for a possible future feature where you would be able to set the default tab instead of it being hardcoded. Existing URL query strings are retained by the redirection, retaining backwards-compatibility: /performers/1?sortby=date will redirect to /performers/1/scenes?sortby=date for example.
    Edit: This is now just a refactor of the tab handling - the behaviour should match how it was before. I'll leave that change for a subsequent PR implementing [Feature] Global settings option to set the default opened nav-tab (for Performer, Tag, Studio pages) #3961.
  • And lastly, refactor to use classnames to generate the class string for the .detail-header instead of doing it manually with a template string - it just looks a bit cleaner.

This ended up being a lot bigger than I had anticipated, because I kept stumbling across things to refactor and couldn't help myself. I'm happy to split anything out into separate PRs if necessary.

@AdultSun
Copy link
Contributor

AdultSun commented Aug 2, 2023

For what it's worth, I've always thought of it as "StashIDs" as well. It feels like that's been the most commonly used spelling too, both within the UI and in conversation.

Copy link
Collaborator

@cj12312021 cj12312021 left a comment

Choose a reason for hiding this comment

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

I didn't run into any issues with the changes during my testing. I suspect the URL changes you made will break a lot of user scripts, but they can be updated.

import { useEffect } from "react";

export function useScrollToTopOnMount() {
useEffect(() => {
Copy link
Collaborator

@cj12312021 cj12312021 Aug 3, 2023

Choose a reason for hiding this comment

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

This makes sense. It wasn't this solution that it sunk it that useEffect's run on render.

@@ -213,7 +213,7 @@ export const PerformerDetailsPanel: React.FC<IPerformerDetails> = ({
fullWidth={fullWidth}
/>
<DetailItem
id="StashIDs"
id="stash_ids"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was actually under the impression that StashID wasn't meant to be translated. I didn't realize a location string existed for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I only noticed because I was getting a console error about a missing intl string - react-intl's behaviour of just showing the ID when no intl string exists isn't meant to actually be used, it's just a fallback so that at least something is shown.

@DingDongSoLong4 DingDongSoLong4 force-pushed the details-redesign-tweaks branch 3 times, most recently from a687ee3 to 08e002f Compare August 5, 2023 17:14
@WithoutPants WithoutPants added the improvement Something needed tweaking. label Aug 7, 2023
@WithoutPants WithoutPants added this to the Version 0.22.0 milestone Aug 7, 2023
@WithoutPants WithoutPants merged commit 5dbf179 into stashapp:develop Aug 7, 2023
2 checks passed
@DingDongSoLong4 DingDongSoLong4 deleted the details-redesign-tweaks branch August 8, 2023 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Something needed tweaking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants