Skip to content

Commit

Permalink
Merge pull request #2382 from Pylons-tech/fix/publishingAndImageAppea…
Browse files Browse the repository at this point in the history
…rToFail

fix: publishing an image appear to fail
  • Loading branch information
MikeSofaer authored May 9, 2024
2 parents da1b298 + c5c8ea3 commit c08f4c0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
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

0 comments on commit c08f4c0

Please sign in to comment.