feat: lots of fixes
This commit is contained in:
27
lib/global_location_store.dart
Normal file
27
lib/global_location_store.dart
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:ot_viewer_app/owntracks_api.dart';
|
||||
|
||||
class GlobalLocationStoreState {
|
||||
final IMap<(String, String), Point> locations;
|
||||
|
||||
GlobalLocationStoreState({required this.locations});
|
||||
|
||||
@override
|
||||
String toString() => 'GlobalLocationStoreState(locations: $locations)';
|
||||
}
|
||||
|
||||
// Define the Cubit
|
||||
class GlobalLocationStoreCubit extends Cubit<GlobalLocationStoreState> {
|
||||
GlobalLocationStoreCubit() : super(GlobalLocationStoreState(locations: IMap(const {})));
|
||||
|
||||
// Function to update the points
|
||||
void updatePoint(String user, String device, Point point) {
|
||||
// Create a new map with the updated point
|
||||
final updatedLocations = state.locations.add((user, device), point);
|
||||
// Emit the new state
|
||||
emit(GlobalLocationStoreState(locations: updatedLocations));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user