fix: removed useless dependencies
This commit is contained in:
parent
981dce5bfe
commit
48bcf0b1f8
10 changed files with 5 additions and 37 deletions
|
|
@ -35,8 +35,7 @@ class AuthRepository extends ChangeNotifier {
|
|||
case Error():
|
||||
return Result.error(result.error);
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
debugPrintStack(stackTrace: stackTrace);
|
||||
} catch (e) {
|
||||
return Result.error(Exception(e));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:seshat/config/constants.dart';
|
||||
|
|
@ -50,17 +49,13 @@ class ApiClient {
|
|||
Uri.parse("https://$apiBasePath/book/ean/$ean"),
|
||||
headers: headers,
|
||||
);
|
||||
debugPrint("\n\n\n\nGOT : ${response.statusCode}\n\n\n\n");
|
||||
if (response.statusCode == 200) {
|
||||
debugPrint("\n\n\n\nWITH : ${response.body}\n\n\n\n");
|
||||
final json = jsonDecode(response.body);
|
||||
return Result.ok(Book.fromJSON(json));
|
||||
} else {
|
||||
debugPrintStack();
|
||||
return Result.error(Exception("The book was not found"));
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
debugPrintStack(stackTrace: stackTrace);
|
||||
} catch (e) {
|
||||
return Result.error(Exception("API $e"));
|
||||
} finally {
|
||||
client.close();
|
||||
|
|
@ -88,7 +83,6 @@ class ApiClient {
|
|||
"owner_id": owner.id,
|
||||
"price": price,
|
||||
});
|
||||
debugPrint("\n\n\n\nSENDING : ${body}\n\n\n\n");
|
||||
final response = await client.post(
|
||||
Uri.parse("https://$apiBasePath/book_instance"),
|
||||
headers: headers,
|
||||
|
|
@ -96,15 +90,13 @@ class ApiClient {
|
|||
);
|
||||
if (response.statusCode == 201) {
|
||||
final json = jsonDecode(response.body);
|
||||
debugPrint("\n\n\n\nRECEIVED : ${json}\n\n\n\n");
|
||||
return Result.ok(BookInstance.fromJSON(json));
|
||||
} else if (response.statusCode == 403) {
|
||||
return Result.error(Exception("You don't own that book instance"));
|
||||
} else {
|
||||
return Result.error(Exception("Something wrong happened"));
|
||||
}
|
||||
} catch (e, stack) {
|
||||
debugPrintStack(stackTrace: stack);
|
||||
} catch (e) {
|
||||
return Result.error(Exception(e));
|
||||
} finally {
|
||||
client.close();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:seshat/config/constants.dart';
|
||||
import 'package:seshat/utils/result.dart';
|
||||
|
|
@ -61,7 +60,7 @@ class AuthClient {
|
|||
} else {
|
||||
return Result.error(Exception("Token creation error"));
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
} catch (e) {
|
||||
return Result.error(Exception(e));
|
||||
} finally {
|
||||
client.close();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:seshat/config/constants.dart';
|
||||
|
|
@ -27,32 +26,24 @@ class WebsocketClient {
|
|||
|
||||
Future<void> connect() async {
|
||||
await _initStore();
|
||||
debugPrint("\n\n\n\nWEBSOCKET STORE IS READY\n\n\n\n");
|
||||
if (_channel != null) return;
|
||||
|
||||
debugPrint("\n\n\n\nWEBSOCKET WILL CONNECT\n\n\n\n");
|
||||
_channel = WebSocketChannel.connect(Uri.parse("wss://$apiBasePath/ws"));
|
||||
debugPrint("\n\n\n\nWEBSOCKET IS CONNECTING\n\n\n\n");
|
||||
|
||||
await _channel!.ready;
|
||||
debugPrint("\n\n\n\nWEBSOCKET IS READY\n\n\n\n");
|
||||
var token = await _secureStorage!.read(key: "token");
|
||||
|
||||
_channel!.sink.add(jsonEncode({"token": "$token"}));
|
||||
_channel!.stream.listen((message) {
|
||||
debugPrint("\n\n\n\n[1] Received : $message\n\n\n\n");
|
||||
_baseController.add(message);
|
||||
});
|
||||
var data = await _baseController.stream.first;
|
||||
debugPrint("\n\n\n\n$data\n\n\n\n");
|
||||
var result = jsonDecode(data);
|
||||
|
||||
if (result["type"] == "auth_success") {
|
||||
debugPrint("\n\n\n\nSUCCESS !\n\n\n\n");
|
||||
sub = _baseController.stream.listen(
|
||||
(message) {
|
||||
final Map<String, dynamic> data = jsonDecode(message);
|
||||
debugPrint("\n\n\n\n[2] Transfered : $message\n\n\n\n");
|
||||
switch (data["type"]) {
|
||||
case "new_owner":
|
||||
final owner = Owner.fromJSON(data["data"]);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class AddViewModel extends ChangeNotifier {
|
|||
String lastName,
|
||||
String contact,
|
||||
) async {
|
||||
debugPrint("\n\n\n\n(2) TRANFERRING\n\n\n\n");
|
||||
final result = await _ownerRepository.addOwner(
|
||||
firstName,
|
||||
lastName,
|
||||
|
|
@ -62,9 +61,7 @@ class AddViewModel extends ChangeNotifier {
|
|||
|
||||
switch (secondResult) {
|
||||
case Ok():
|
||||
debugPrint("\n\n\n${secondResult.value.length}");
|
||||
_owners = secondResult.value;
|
||||
debugPrint("\n\n\n${_owners.length}");
|
||||
_currentOwner = result.value;
|
||||
notifyListeners();
|
||||
return Result.ok(result.value);
|
||||
|
|
@ -142,7 +139,7 @@ class AddViewModel extends ChangeNotifier {
|
|||
);
|
||||
isLoaded = true;
|
||||
case Error():
|
||||
debugPrint("Oupsie daysie, ${result.error}");
|
||||
break;
|
||||
}
|
||||
notifyListeners();
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,6 @@ class _AddPageState extends State<AddPage> {
|
|||
);
|
||||
break;
|
||||
case Error():
|
||||
debugPrintStack();
|
||||
debugPrint(result.error.toString());
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Erreur : ${result.error}"),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:seshat/domain/models/bal.dart';
|
||||
import 'package:seshat/domain/models/book.dart';
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ class FormPopup extends StatelessWidget {
|
|||
child: InkWell(
|
||||
splashColor: Colors.blue.withAlpha(30),
|
||||
onTap: () {
|
||||
debugPrint('Card tapped.');
|
||||
Navigator.of(context).pop();
|
||||
showDialog(
|
||||
context: context,
|
||||
|
|
@ -57,7 +56,6 @@ class FormPopup extends StatelessWidget {
|
|||
child: InkWell(
|
||||
splashColor: Colors.blue.withAlpha(30),
|
||||
onTap: () {
|
||||
debugPrint('Card tapped.');
|
||||
Navigator.of(context).pop();
|
||||
showDialog(
|
||||
context: context,
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ class _OwnerPopupState extends State<OwnerPopup> {
|
|||
if (showNewOwner) {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
debugPrint("\n\n\n\n(1) SENDING REQUEST\n\n\n\n");
|
||||
await widget.viewModel.addOwner(
|
||||
firstName!,
|
||||
lastName!,
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ class LoginViewModel extends ChangeNotifier {
|
|||
Future<Result<void>> _login((String, String) credentials) async {
|
||||
final (username, password) = credentials;
|
||||
final result = await _authRepository.login(username, password);
|
||||
if (result is Error<void>) {
|
||||
debugPrint("Hehe no");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue