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

Update list of trocador providers to be fetched from the api #1379

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Serhii-Borodenko
Copy link
Contributor

@Serhii-Borodenko Serhii-Borodenko commented Apr 12, 2024

Issue Number (if Applicable): Fixes #

Description

Please include a summary of the changes and which issue is fixed / feature is added.

Pull Request - Checklist

  • Initial Manual Tests Passed
  • Double check modified code and verify it with the feature/task requirements
  • Format code
  • Look for code duplication
  • Clear naming for variables and methods

@@ -10,6 +11,9 @@ abstract class TrocadorProvidersViewModelBase with Store {

final SettingsStore _settingsStore;

Future<List<TrocadorPartners>> fetchTrocadorPartners() async =>
await TrocadorExchangeProvider().fetchProviders();
Copy link
Contributor

Choose a reason for hiding this comment

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

enhancement
better pass the TrocadorExchangeProvider as a dependency

Copy link
Contributor

Choose a reason for hiding this comment

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

also update the settings store here too, you can have it only in settings store and use it in both view models (this one and the exchange view model)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 1435 to 1439
void initializeTrocadorProviderStates() async{
final availableProviders = await TrocadorExchangeProvider().fetchProviders();
for (var provider in availableProviders) {
final savedState = _sharedPreferences.getBool(provider.name) ?? true;
trocadorProviderStates[provider.name] = savedState;
Copy link
Contributor

Choose a reason for hiding this comment

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

nope, we said that we will not make an API call once the app is opened.
fetch the providers and update the list in only 2 cases

  1. user enters the Exchange page and Trocador is one of the selected providers
  2. user enters the Trocador providers page

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed unnecessary API call.

List<ExchangeProvider> get _allProviders {
trocadorProvider = TrocadorExchangeProvider(
useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates);
updateTrocadorProviderStates(trocadorProvider);
Copy link
Contributor

Choose a reason for hiding this comment

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

not a good place to call the API, like this the API will get called any time this getter is accessed.
move it to the constructor so it's only called once

Copy link
Contributor Author

Choose a reason for hiding this comment

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

calling the API only if the chosen provider is Trocador.

Comment on lines 346 to 350
name: json['name'] as String,
rating: json['rating'] as String,
insurance: json['insurance'] as double,
enabledMarkup: json['enabledmarkup'] as bool,
eta: json['eta'] as double,
Copy link
Contributor

Choose a reason for hiding this comment

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

make all of them nullable, since this is not our API and we are not 100% sure they will keep all those mandatory and returned every time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
'selected Trocador provider: ${trade.providerName}',
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing Localisation

dart ./tool/append_translation.dart selected_trocador_provider "selected Trocador provider: {trocador_provider}"

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
'selected Trocador provider: ${trade.providerName}',
S.of(context).selected_trocador_provider(trade.providerName),

After appending the localisation of course :)

}
var providerStates = trocadorProvidersViewModel.providerStates;
if (providerStates.isEmpty) {
return Center(child: Text('No providers available'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing Localisation?

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.

None yet

3 participants