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

fix: publishing an image appear to fail #2382

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
52 changes: 36 additions & 16 deletions wallet/lib/services/data_stores/remote_data_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import 'package:pylons_wallet/utils/dependency_injection/dependency_injection.da
import 'package:pylons_wallet/utils/enums.dart';
import 'package:pylons_wallet/utils/extension.dart';
import 'package:pylons_wallet/utils/failure/failure.dart';
import 'package:retry/retry.dart';
import 'package:transaction_signing_gateway/model/account_lookup_key.dart';
import 'package:transaction_signing_gateway/transaction_signing_gateway.dart';

Expand Down Expand Up @@ -901,18 +902,26 @@ class RemoteDataStoreImp implements RemoteDataStore {

@override
Future<pylons.Recipe> getRecipe({required CookbookId cookBookId, required RecipeId recipeId}) async {
final pylons.QueryClient queryClient = getQueryClient();
final request = pylons.QueryGetRecipeRequest.create()
..cookbookId = cookBookId.toString()
..id = recipeId.toString();

final response = await queryClient.recipe(request);
try{
const retry = RetryOptions();
final response = await retry.retry(()async {
final pylons.QueryClient queryClient = getQueryClient();
final request = pylons.QueryGetRecipeRequest.create()
..cookbookId = cookBookId.toString()
..id = recipeId.toString();

if (response.hasRecipe()) {
return response.recipe;
}
final response = await queryClient.recipe(request);
return response;
}, retryIf: (_) => true ,);

throw RecipeNotFoundFailure(LocaleKeys.recipe_not_found.tr());
if (response.hasRecipe()) {
return response.recipe;
}
throw RecipeNotFoundFailure(LocaleKeys.recipe_not_found.tr());
} catch (_) {
throw RecipeNotFoundFailure(LocaleKeys.recipe_not_found.tr());
}
}

@override
Expand Down Expand Up @@ -958,15 +967,26 @@ class RemoteDataStoreImp implements RemoteDataStore {

@override
Future<pylons.Cookbook> getCookbookBasedOnId({required String cookBookId}) async {
final pylons.QueryClient queryClient = getQueryClient();
final request = pylons.QueryGetCookbookRequest.create()..id = cookBookId;
try{
const retry = RetryOptions();

final response = await queryClient.cookbook(request);
if (response.hasCookbook()) {
return response.cookbook;
}
final response = await retry.retry(()async {
final pylons.QueryClient queryClient = getQueryClient();
final request = pylons.QueryGetCookbookRequest.create()..id = cookBookId;

throw CookBookNotFoundFailure(LocaleKeys.cookbook_not_found.tr());
final response = await queryClient.cookbook(request);
return response;
}, retryIf: (_) => true,);

if (response.hasCookbook()) {
return response.cookbook;
}

throw CookBookNotFoundFailure(LocaleKeys.cookbook_not_found.tr());

} catch (_) {
throw CookBookNotFoundFailure(LocaleKeys.cookbook_not_found.tr());
}
}

@override
Expand Down
1 change: 1 addition & 0 deletions wallet/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dependencies:
provider: ^6.0.3
qr_flutter: ^4.0.0

retry: ^3.1.2
share_plus: ^6.0.0
shared_preferences: ^2.0.12
shimmer_animation: ^2.1.0+1
Expand Down
Loading