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: [#175114153] Force update birthplace FiscalCodeScreen #2277

Merged
merged 6 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ts/screens/profile/FiscalCodeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ class FiscalCodeScreen extends React.PureComponent<Props, State> {
const maybeCodiceCatastale = CodiceCatastale.decode(
this.props.profile.fiscal_code.substring(11, 15)
);
// if municipality data are none we request a load
if (pot.isNone(this.props.municipality.data)) {
maybeCodiceCatastale.map(c => this.props.loadMunicipality(c));
}

maybeCodiceCatastale.map(c => this.props.loadMunicipality(c));
Undermaken marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
6 changes: 4 additions & 2 deletions ts/store/reducers/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@ export default function content(
};

case getType(contentMunicipalityLoad.request):
const codiceCatastale = state.municipality.codiceCatastale;
const municipalityData = state.municipality.data;
return {
...state,
municipality: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
municipality: {
municipality: {
codiceCatastale: pot.toLoading(codiceCatastale),
data: pot.toLoading(municipalityData)
}

we need to preserve the loading state
In that way the pot could be loading (noneLoading, if there is no value) and previous value (some, error, loading) if there is a value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it!

Just for knowledge my code can bring to some wrong behaviour?

Copy link
Contributor

@Undermaken Undermaken Oct 13, 2020

Choose a reason for hiding this comment

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

Yes it does. It doesn't represent correctly the request status (loading -> success / failure)
Only when the store is empty (isNone) the status will be right (noneLoading)
In all other cases (some, error) when a request starts we won't have the status loading.

This could be a problem if we have to show a loader in the meantime: it will be shown only under specific scenario

codiceCatastale: pot.noneLoading,
data: pot.noneLoading
codiceCatastale: pot.toLoading(codiceCatastale),
data: pot.toLoading(municipalityData)
}
};

Expand Down