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
base: main
Are you sure you want to change the base?
Update list of trocador providers to be fetched from the api #1379
Conversation
@@ -10,6 +11,9 @@ abstract class TrocadorProvidersViewModelBase with Store { | |||
|
|||
final SettingsStore _settingsStore; | |||
|
|||
Future<List<TrocadorPartners>> fetchTrocadorPartners() async => | |||
await TrocadorExchangeProvider().fetchProviders(); |
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.
enhancement
better pass the TrocadorExchangeProvider
as a dependency
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.
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)
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.
done
lib/store/settings_store.dart
Outdated
void initializeTrocadorProviderStates() async{ | ||
final availableProviders = await TrocadorExchangeProvider().fetchProviders(); | ||
for (var provider in availableProviders) { | ||
final savedState = _sharedPreferences.getBool(provider.name) ?? true; | ||
trocadorProviderStates[provider.name] = savedState; |
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.
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
- user enters the Exchange page and Trocador is one of the selected providers
- user enters the Trocador providers page
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.
removed unnecessary API call.
List<ExchangeProvider> get _allProviders { | ||
trocadorProvider = TrocadorExchangeProvider( | ||
useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates); | ||
updateTrocadorProviderStates(trocadorProvider); |
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.
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
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.
calling the API only if the chosen provider is Trocador.
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, |
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.
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
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.
done
…be-fetched-from-the-API
This reverts commit 5722ed7.
Padding( | ||
padding: const EdgeInsets.only(top: 8.0), | ||
child: Text( | ||
'selected Trocador provider: ${trade.providerName}', |
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.
Missing Localisation
dart ./tool/append_translation.dart selected_trocador_provider "selected Trocador provider: {trocador_provider}"
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.
'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')); |
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.
Missing Localisation?
Issue Number (if Applicable): Fixes #
Description
Please include a summary of the changes and which issue is fixed / feature is added.
Pull Request - Checklist