From 3c3ee6d7e931d0966bad77b09447caff717ef6cc Mon Sep 17 00:00:00 2001 From: delanierlucas Date: Sat, 19 Nov 2022 18:54:07 +0100 Subject: [PATCH] fix bug when deleting in discovery --- Sources/dafl_project_flutter/lib/model/spot.dart | 8 +++----- Sources/dafl_project_flutter/lib/model/user.dart | 3 +++ .../lib/views/pages/main/w_discovery.dart | 1 - .../dafl_project_flutter/lib/views/pages/main/w_spot.dart | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/dafl_project_flutter/lib/model/spot.dart b/Sources/dafl_project_flutter/lib/model/spot.dart index 84a5105..f47b488 100644 --- a/Sources/dafl_project_flutter/lib/model/spot.dart +++ b/Sources/dafl_project_flutter/lib/model/spot.dart @@ -8,12 +8,10 @@ class Spot { @override bool operator ==(Object other) => - identical(this, other) || other is Spot && - runtimeType == other.runtimeType && - userId == other.userId && - music == other.music; + runtimeType == other.runtimeType && + userId == other.userId; @override - int get hashCode => userId.hashCode ^ music.hashCode; + int get hashCode => music.hashCode; } diff --git a/Sources/dafl_project_flutter/lib/model/user.dart b/Sources/dafl_project_flutter/lib/model/user.dart index a16110f..d9831af 100644 --- a/Sources/dafl_project_flutter/lib/model/user.dart +++ b/Sources/dafl_project_flutter/lib/model/user.dart @@ -47,6 +47,7 @@ class User { } listSpots() { + print('ajout test'); Future rep = Location.sendCurrentLocation(); //ex : dorian-2d2s52a15d2a5,audric-2x5s2az3d1s5wx5s1,lucas-s2a5d25a2a25d @@ -58,7 +59,9 @@ class User { List tab2 = element.split("-"); if (!spots.contains(Spot(tab2[0], Music(tab2[1])))) { spots.add(Spot(tab2[0], Music(tab2[1]))); + return; } + print('deja présent'); } }); } diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart index 63c0495..3220532 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart @@ -148,7 +148,6 @@ class _DiscoveryListState extends State { print(listDiscovery[reversedIndex].name); MyApp.controller.currentUser.discovery .remove(listDiscovery[reversedIndex]); - setState(() {}); return true; } if (direction == DismissDirection.startToEnd) { diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart index c7f4a15..3f908e3 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:ui'; import 'package:rive/rive.dart' as riv;