From 948b16cac3b00cd23a8e8a47f19a0cb4a64401be Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Sun, 30 Jul 2023 21:38:30 +0100 Subject: [PATCH] Fix bus stops addition --- uni/lib/model/providers/lazy/bus_stop_provider.dart | 9 +++++++++ .../view/bus_stop_selection/widgets/bus_stop_search.dart | 1 + 2 files changed, 10 insertions(+) diff --git a/uni/lib/model/providers/lazy/bus_stop_provider.dart b/uni/lib/model/providers/lazy/bus_stop_provider.dart index 7beb63a41..aa28e0809 100644 --- a/uni/lib/model/providers/lazy/bus_stop_provider.dart +++ b/uni/lib/model/providers/lazy/bus_stop_provider.dart @@ -53,6 +53,15 @@ class BusStopProvider extends StateProviderNotifier { updateStatus(RequestStatus.busy); await fetchUserBusTrips(); + if (_configuredBusStops.containsKey(stopCode)) { + (_configuredBusStops[stopCode]!.configuredBuses).clear(); + _configuredBusStops[stopCode]! + .configuredBuses + .addAll(stopData.configuredBuses); + } else { + _configuredBusStops[stopCode] = stopData; + } + final db = AppBusStopDatabase(); await db.setBusStops(configuredBusStops); } diff --git a/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart b/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart index 92d872a3b..9f24bccb4 100644 --- a/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart +++ b/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart @@ -15,6 +15,7 @@ class BusStopSearch extends SearchDelegate { BusStopSearch() { getDatabase(); } + List suggestionsList = []; late final AppBusStopDatabase db; String? stopCode;