-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
A lot of rendering refactors related to libraries (and a few extras) #1267
Conversation
@@ -143,7 +143,6 @@ export class LegendaryLibrary { | |||
|
|||
if (fullRefresh) { | |||
try { | |||
logInfo('Refreshing Epic Games...', LogPrefix.Legendary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refresh
function called right after this line also prints this same string to the logs, it gave the impression that the epic library was getting refreshed twice when it didn't.
@@ -32,7 +34,7 @@ i18next | |||
interpolation: { | |||
escapeValue: false | |||
}, | |||
lng: 'en', | |||
lng: storage.getItem('language') || 'en', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when selecting a language other than en
, the app was loaded in english at boot for a moment and then changed to the user's language, which looked glitchy and triggered an extra re-render
@@ -184,9 +281,9 @@ export default function Library(): JSX.Element { | |||
|
|||
<h3 className="libraryHeader">{titleWithIcons()}</h3> | |||
|
|||
{refreshing && <UpdateComponent inline />} | |||
{refreshing && !refreshingInTheBackground && <UpdateComponent inline />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this refreshingInTheBackground
to be able to differenciate when the library was being refreshed in the background and in the foreground
@@ -79,7 +81,7 @@ export class GlobalState extends PureComponent<Props> { | |||
return games | |||
} | |||
state: StateProps = { | |||
category: 'epic', | |||
category: storage.getItem('category') || 'epic', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can load all these local storage data here instead of in the componentDidMount callback
with the previous code, if you close heroic when in the gog library, when you open heroic it will open it in the epic library for a moment and then change to gog, which looked glitchy and triggered an extra re-render
This is pretty good for performance. As much stuff we can remove from GlobalState the better. Especially to refactor it as a functional component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Will take some time to test it later.
Tested here and looks good. |
just to confirm, can I merge this? I know you want to make a new release soon and maybe you prefer to leave this to after the release since it's a refactor, I'm happy to get this merged but I understand if you prefer to wait |
Yes, perhaps we should wait for the release then and then put this on on a minor release. |
thanks, just pushed a fix for this, but let's wait for after the release and then this can be tested more as part of the next betas 👍, I plan to do other refactors too |
…uncher into refactor/optimize-library-refresh
I think this one can be merged :) |
merging this then, so I can see if it adds conflicts to other stuff |
This PR includes a lot of refactoring to improve the calculations done in each render:
numberOfGames
calculation from GlobalState to Header (same as before, calculated in every render, even when not needed) and memoize itI'll add more comments on the diff of the PR
Use the following Checklist if you have changed something on the Backend or Frontend: