mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Adds debug message helper
This commit is contained in:
parent
2e86a02343
commit
625d29fcf1
@ -16,6 +16,7 @@ import "package:flutter_cache_manager/flutter_cache_manager.dart";
|
||||
|
||||
import "package:inventree/widget/dialogs.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
import "package:inventree/inventree/sentry.dart";
|
||||
import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/user_profile.dart";
|
||||
|
@ -7,9 +7,23 @@
|
||||
* supressing trailing zeroes
|
||||
*/
|
||||
|
||||
import "dart:io";
|
||||
|
||||
import "package:audioplayers/audioplayers.dart";
|
||||
import "package:one_context/one_context.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Display a debug message if we are in testing mode, or running in debug mode
|
||||
*/
|
||||
void debug(dynamic msg) {
|
||||
|
||||
if (Platform.environment.containsKey("FLUTTER_TEST")) {
|
||||
print("DEBUG: ${msg.toString()}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String simpleNumberString(double number) {
|
||||
// Ref: https://stackoverflow.com/questions/55152175/how-to-remove-trailing-zeros-using-dart
|
||||
|
||||
@ -19,7 +33,7 @@ String simpleNumberString(double number) {
|
||||
/*
|
||||
* Play an audio file from the requested path.
|
||||
*
|
||||
* Note: If OneContext module fails the 'hasConext' check,
|
||||
* Note: If OneContext module fails the 'hasContext' check,
|
||||
* we will not attempt to play the sound
|
||||
*/
|
||||
Future<void> playAudioFile(String path) async {
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
import "package:sembast/sembast.dart";
|
||||
|
||||
import "package:inventree/helpers.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
|
||||
class UserProfile {
|
||||
@ -85,7 +86,7 @@ class UserProfileDBManager {
|
||||
Future<bool> addProfile(UserProfile profile) async {
|
||||
|
||||
if (profile.name.isEmpty || profile.username.isEmpty || profile.password.isEmpty) {
|
||||
print("Profile missing required values - not adding to database");
|
||||
debug("addProfile() : Profile missing required values - not adding to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -93,7 +94,7 @@ class UserProfileDBManager {
|
||||
final bool exists = await profileNameExists(profile.name);
|
||||
|
||||
if (exists) {
|
||||
print("UserProfile '${profile.name}' already exists");
|
||||
debug("addProfile() : UserProfile '${profile.name}' already exists");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -120,7 +121,7 @@ class UserProfileDBManager {
|
||||
|
||||
// Prevent invalid profile data from being updated
|
||||
if (profile.name.isEmpty || profile.username.isEmpty || profile.password.isEmpty) {
|
||||
print("Profile missing required values - not updating");
|
||||
debug("updateProfile() : Profile missing required values - not updating");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -151,11 +152,11 @@ class UserProfileDBManager {
|
||||
|
||||
final profiles = await store.find(await _db);
|
||||
|
||||
print("getSelectedProfile() - ${profiles.length} profiles available - selected = ${selected}");
|
||||
debug("getSelectedProfile() : ${profiles.length} profiles available - selected = ${selected}");
|
||||
|
||||
for (int idx = 0; idx < profiles.length; idx++) {
|
||||
|
||||
print("- Checking ${idx} - key = ${profiles[idx].key} - ${profiles[idx].value.toString()}");
|
||||
debug("- Checking ${idx} - key = ${profiles[idx].key} - ${profiles[idx].value.toString()}");
|
||||
|
||||
if (profiles[idx].key is int && profiles[idx].key == selected) {
|
||||
return UserProfile.fromJson(
|
||||
|
Loading…
x
Reference in New Issue
Block a user