Fix station selection

If current station was null, you couldn't select another station
This commit is contained in:
Nathan McRae 2025-01-10 21:43:35 -08:00
parent 4444b82edc
commit 9f59fc813f

View File

@ -79,16 +79,18 @@ public class NumbersStationController implements Initializable {
selectStationStage.setScene(new Scene(root)); selectStationStage.setScene(new Scene(root));
selectStationStage.show(); selectStationStage.show();
selectStationStage.setOnHiding(event -> { selectStationStage.setOnHiding(event -> {
selectedStationName.set((String) selectStationStage.getUserData()); String newStationName = (String)selectStationStage.getUserData();
if (selectedStation != null) { StationSettings newSelectedStation = settings.getStations().stream()
selectedStation = settings.getStations().stream() .filter(station -> station.getName().equals(newStationName))
.filter(station -> station.getName().equals(selectedStationName.get()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
} if (newSelectedStation != null) {
selectedStation = newSelectedStation;
selectedStationName.set(newStationName);
settings.setSelectedStationName(selectedStationName.get()); settings.setSelectedStationName(selectedStationName.get());
settings.save(); settings.save();
}
}); });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();