-
-
Notifications
You must be signed in to change notification settings - Fork 392
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
OBPIH-5300 Fix statuses on list pages/reason codes to be refetched after change of locale #3780
Conversation
…translation (session.user.locale)
…o they pass sessionVersion number as param to their reducers
…rsion of a list page differs from the actual session version
…r the reason codes issue
…crowdin and make them react for any language change
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 want to get a better understanding of the options so let's discuss this on the tech huddle tomorrow or Wednesday.
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 don't like this session version
approach. Just store in redux the languages that we got statuses for (or the latest one) and refetch it (or not) depending on the current language comparing to this value stored. Or if the issue is caused by the redux-persist and that approach still won't work, then simply pull the statuses on entering the list with todo
to go back to pulling from redux once we will have everything covered in react.
@awalkowiak What about changing the approach of translating the statuses that I proposed yesterday, so we just return the key to the frontend side and we use this key inside
instead of label being done like this, I'd just return something like |
@kchelstowski yeah that should be fine, i forgot about this discussion. |
…and refetch when changing the language
dc1e18e
to
ff69527
Compare
@awalkowiak I tried to go with my proposed solution, but seeing how much complexed code I have to change/to add in order for this to work, I decided not to do it for now - I just had to edit many |
Refetching statuses instead of trying to keep state about whether statuses need to be refetched. |
The issue was exactly what I've thought about during our planning - the statuses/reason codes are stored by redux store, and once they are fetched, they weren't refetched when the locale was changed. Obviously the easiest way (but not correct, which I'll explain) would be to make
useEffect
reacting to each locale change, but that wouldn't be enough here. Why? Because we still have GSP side - if we would change the locale on the GSP side and then go to any list page on the React side (assuming that we've been on this list page already before and we once fetched the statuses), we wouldn't get the correct label of the statuses, because changing the language on the GSP side wouldn't make our React'suseEffect
being triggered.Going into details, it wouldn't be that easy to create a
useEffect
reacting for locale change and refetching the statuses, because we'd have to do it e.g. in theMainRouter
and we would have to refetch ALL the statuses, for every single list page at once (because how would I know on what list page will I go in the future potentially?), which would be a bad idea, why would I need a fetch of statuses for Invoice list if I weren't to go there?I needed to come up with some other solution which for now doesn't even matter, because we still don't have full React, and whenever we change the page, we don't use SPA (single page application routing), but we make the page being "refreshed" after each redirect, which makes the
getAppContext
run whenever we change the page, which we will get rid of if we have full React - we would have to fetch the session info only once. This is also why Artur has added the redux-persist, because without it, we were losing whole Redux data after each redirect, which actually was a negation of Redux's goal.My preposition was to add some kind of "counter" to the
sessionReducer
and all of list pages reducers calledsessionVersion
- its usage is very simple - whenever we fetch the session info or change the locale, we increment the counter for thesessionReducer
and then going to any list page we compare thesessionReducer
's counter with the list page's counter - if they are different, it means that we either changed the language before going to that list page or refetched the session info - so with that information I know if I have to refetch the statuses/reason codes to have a proper label. The advantage of that solution is that if I go to that list page again and my counters are equal, I DO NOT have to refetch the statuses.Of course for now anyway we will have to, because we don't have full React yet, but I wanted this solution to be "ready" for the full React, so we will have less "fetching refactor" in the future.
I also wanted to avoid refetching statuses for all of the list pages whenever I change the locale, because it would be bad in terms of performance especially if I weren't even ever to go on a specific list page.
I also fixed the stock transfer list's statuses, so they are translatable by crowdin. There was also one more mystery about the reason codes on the backend side - the locale to translate the label was taken from the
session.user.locale
, but after my latest update to localization mode, we make thesession.locale
, not thesession.user.locale
"higher" in order.