-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 4423 - specific "Not connected to internet" displayed error (#4455
) * feat: 4423 - specific "Not connected to internet" displayed error Impacted files: * `barcode_product_query.dart`: removed useless `try` as already `catch`'ed * `continuous_scan_model.dart`: removed the `codeInvalid` case that could never happen * `fetched_product.dart`: refactored with explicit constructors and additional exception and connectivity fields; removed the `codeInvalid` case that could never happen * `new_product_page.dart`: minor refactoring * `product_dialog_helper.dart`: removed the `codeInvalid` case that could never happen; minor refactoting * `product_list_item_simple.dart`: removed the `codeInvalid` case that could never happen * `product_loader_page.dart`: removed useless `try` as already `catch`'ed * `product_refresher.dart`: added a specific "You're not connected to the internet" error message; refactored using more `FetchedProduct`; removed useless method * `pubspec.lock`: wtf * `pubspec.yaml`: added package `connectivity_plus` * `question_card.dart`: refactored using `FetchedProduct` * feat: 4423 - fixed pubspec.yaml * feat: 4423 - new "server down" message after a ping attempt Impacted files: * `fetched_product.dart`: added field `failedPingedHost` where we store the host that we couldn't ping * `generated_plugin_registrant.cc`: wtf * `generated_plugins.cmake`: wtf * `GeneratedPluginRegistrant.swift`: wtf * `main.dart`: registered `DartPingIOS` * `product_refresher.dart`: now trying to ping the server if exception and connection * `pubspec.lock`: wtf * `pubspec.yaml: added packages `dart_ping` and `dart_ping_ios` * feat: 4423 - stupid lint check part 1 * feat: 4423 - stupid lint check part 2 * feat: 4423 - stupid lint check part 3 * feat: 4423 - stupid lint check part 5 * feat: 4423 - localizations Impacted files: * `app_en.arb`: 4 new labels when we couldn't retrieve a product (not found, no internet, server down, server error) * `product_refresher.dart`: used the new labels
- Loading branch information
1 parent
ff10b44
commit f79bae6
Showing
16 changed files
with
240 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,63 @@ | ||
import 'package:connectivity_plus/connectivity_plus.dart'; | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
|
||
/// Status of a "fetch [Product]" operation | ||
enum FetchedProductStatus { | ||
// found locally or from internet | ||
ok, | ||
internetNotFound, | ||
internetError, | ||
userCancelled, | ||
codeInvalid, | ||
// TODO(monsieurtanuki): time-out | ||
} | ||
|
||
/// A [Product] that we tried to fetch, but was it successful?.. | ||
class FetchedProduct { | ||
const FetchedProduct._({ | ||
required this.status, | ||
this.product, | ||
this.connectivityResult, | ||
this.exceptionString, | ||
this.failedPingedHost, | ||
}); | ||
|
||
// The reason behind the "ignore": I want to force "product" to be not null | ||
FetchedProduct(final Product product) | ||
const FetchedProduct.found(final Product product) | ||
// ignore: prefer_initializing_formals | ||
: product = product, | ||
status = FetchedProductStatus.ok; | ||
: this._( | ||
status: FetchedProductStatus.ok, | ||
product: product, | ||
); | ||
|
||
/// The internet Product search said it couldn't find the product. | ||
const FetchedProduct.internetNotFound() | ||
: this._(status: FetchedProductStatus.internetNotFound); | ||
|
||
/// The user cancelled the operation. | ||
const FetchedProduct.userCancelled() | ||
: this._(status: FetchedProductStatus.userCancelled); | ||
|
||
/// When the "fetch product" operation didn't go well (no status "ok" here) | ||
FetchedProduct.error(this.status) | ||
: product = null, | ||
assert(status != FetchedProductStatus.ok); | ||
/// When the "fetch product" operation had an internet error. | ||
const FetchedProduct.error({ | ||
required final String exceptionString, | ||
required final ConnectivityResult connectivityResult, | ||
final String? failedPingedHost, | ||
}) : this._( | ||
status: FetchedProductStatus.internetError, | ||
connectivityResult: connectivityResult, | ||
exceptionString: exceptionString, | ||
failedPingedHost: failedPingedHost, | ||
); | ||
|
||
final Product? product; | ||
final FetchedProductStatus status; | ||
|
||
/// When relevant, result of the connectivity check. | ||
final ConnectivityResult? connectivityResult; | ||
|
||
/// When relevant, string of the exception. | ||
final String? exceptionString; | ||
|
||
/// When relevant, host of the query that we couldn't even ping. | ||
final String? failedPingedHost; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.