From 19ad3153e4c8548d35a5a834fab29aed9440d5f3 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 20 Jul 2022 14:18:07 +1000 Subject: [PATCH] Remove and fix some TODO entries (#188) --- lib/api.dart | 28 ++++++++++++++-------------- lib/helpers.dart | 3 ++- lib/inventree/model.dart | 6 ------ lib/inventree/part.dart | 2 -- lib/widget/stock_detail.dart | 2 -- test/api_test.dart | 5 ++--- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 0d8e9682..c68219f9 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -691,16 +691,16 @@ class InvenTreeAPI { showServerError(url, L10().connectionRefused, error.toString()); return; } on TimeoutException { - print("TimeoutException at ${url}"); + debug("TimeoutException at ${url}"); showTimeoutError(url); return; } on HandshakeException catch (error) { - print("HandshakeException at ${url}:"); + debug("HandshakeException at ${url}:"); debug(error.toString()); showServerError(url, L10().serverCertificateError, error.toString()); return; } catch (error, stackTrace) { - print("Server error at ${url}: ${error.toString()}"); + debug("Server error at ${url}: ${error.toString()}"); showServerError(url, L10().serverError, error.toString()); sentryReportError( "api.downloadFile : client.openUrl", @@ -730,8 +730,8 @@ class InvenTreeAPI { } on TimeoutException { showTimeoutError(url); } catch (error, stackTrace) { - print("Error downloading image:"); - print(error.toString()); + debug("Error downloading image:"); + debug(error.toString()); showServerError(url, L10().downloadError, error.toString()); sentryReportError( "api.downloadFile : client.closeRequest", @@ -956,25 +956,25 @@ class InvenTreeAPI { return _request; } on SocketException catch (error) { - print("SocketException at ${url}: ${error.toString()}"); + debug("SocketException at ${url}: ${error.toString()}"); showServerError(url, L10().connectionRefused, error.toString()); return null; } on TimeoutException { - print("TimeoutException at ${url}"); + debug("TimeoutException at ${url}"); showTimeoutError(url); return null; } on CertificateException catch (error) { - print("CertificateException at ${url}:"); - print(error.toString()); + debug("CertificateException at ${url}:"); + debug(error.toString()); showServerError(url, L10().serverCertificateError, error.toString()); return null; } on HandshakeException catch (error) { - print("HandshakeException at ${url}:"); - print(error.toString()); + debug("HandshakeException at ${url}:"); + debug(error.toString()); showServerError(url, L10().serverCertificateError, error.toString()); return null; } catch (error, stackTrace) { - print("Server error at ${url}: ${error.toString()}"); + debug("Server error at ${url}: ${error.toString()}"); showServerError(url, L10().serverError, error.toString()); sentryReportError( "api.apiRequest : openUrl", @@ -1054,8 +1054,8 @@ class InvenTreeAPI { response.error = "SocketException"; response.errorDetail = error.toString(); } on CertificateException catch (error) { - print("CertificateException at ${request.uri.toString()}:"); - print(error.toString()); + debug("CertificateException at ${request.uri.toString()}:"); + debug(error.toString()); showServerError(url, L10().serverCertificateError, error.toString()); } on TimeoutException { showTimeoutError(url); diff --git a/lib/helpers.dart b/lib/helpers.dart index 95586c37..d75e34d1 100644 --- a/lib/helpers.dart +++ b/lib/helpers.dart @@ -44,8 +44,9 @@ void debug(dynamic msg) { if (Platform.environment.containsKey("FLUTTER_TEST")) { debug_messages.add(msg.toString()); - print("DEBUG: ${msg.toString()}"); } + + print("DEBUG: ${msg.toString()}"); } diff --git a/lib/inventree/model.dart b/lib/inventree/model.dart index f11a7130..ffb849a4 100644 --- a/lib/inventree/model.dart +++ b/lib/inventree/model.dart @@ -514,12 +514,6 @@ class InvenTreeModel { return results; } - - // Provide a listing of objects at the endpoint - // TODO - Static function which returns a list of objects (of this class) - - // TODO - Define a "save" / "update" function - // Override this function for each sub-class bool matchAgainstString(String filter) { // Default implementation matches name and description diff --git a/lib/inventree/part.dart b/lib/inventree/part.dart index 9cbc9c84..4cbd0cce 100644 --- a/lib/inventree/part.dart +++ b/lib/inventree/part.dart @@ -57,8 +57,6 @@ class InvenTreePartCategory extends InvenTreeModel { InvenTreeModel createFromJson(Map json) { var cat = InvenTreePartCategory.fromJson(json); - // TODO ? - return cat; } } diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index d214746b..a3026430 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -705,8 +705,6 @@ class _StockItemDisplayState extends RefreshableState { context, MaterialPageRoute(builder: (context) => StockNotesWidget(item)) ); - // TODO: Load notes in markdown viewer widget - // TODO: Make this widget editable? } ) ); diff --git a/test/api_test.dart b/test/api_test.dart index c1a3b48d..33f27604 100644 --- a/test/api_test.dart +++ b/test/api_test.dart @@ -79,8 +79,7 @@ void main() { bool result = await api.connectToServer(); assert(!result); - // TODO: Test the the right 'error message' is returned - // TODO: The request above should throw a 'SockeException' + debugContains("SocketException at"); // Test incorrect login details profile.server = "http://localhost:12345"; @@ -91,7 +90,7 @@ void main() { await api.connectToServer(); assert(!result); - // TODO: Test that the connection attempt above throws an authentication error + debugContains("Token request failed"); assert(!api.checkConnection());