Last changes not published

This commit is contained in:
vjrj 2026-03-05 01:18:27 +01:00
parent ac65ccf990
commit 21ec08303a
43 changed files with 607 additions and 613 deletions

View file

@ -1,16 +1,17 @@
import 'dart:async';
import 'package:bson_objectid/bson_objectid.dart';
import 'package:fires_flutter/models/fireNotification.dart';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:flutter_simple_dependency_injection/injector.dart';
import 'package:just_debounce_it/just_debounce_it.dart';
import 'package:objectid/objectid.dart';
import 'package:redux/redux.dart';
import '../models/appState.dart';
import '../models/fireNotificationsPersist.dart';
import '../models/firesApi.dart';
import '../models/yourLocationPersist.dart';
import '../objectIdUtils.dart';
import 'actions.dart';
// A middleware takes in 3 parameters: your Store, which you can use to
@ -147,16 +148,18 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
.then((List<YourLocation> subscribedLocations) {
// If it succeeds, dispatch a success action with the YourLocations.
// Our reducer will then update the State using these YourLocations.
// print('Subscribed to: ${subscribedLocations.length}');
print('Subscribed to: ${subscribedLocations.length}');
if (subscribedLocations is List) {
// unsubscribe all locally to sync the subs state
localLocations.forEach((location) => location.subscribed = false);
// print('Local persisted: ${localLocations.length}');
print('Local persisted: ${localLocations.length}');
subscribedLocations.forEach((subsLoc) {
localLocations.firstWhere(
var locSubs = localLocations.firstWhere(
(localLocation) => localLocation.id == subsLoc.id, orElse: () {
localLocations.add(subsLoc);
}).subscribed = true;
return subsLoc;
});
locSubs.subscribed = true;
});
}
@ -251,7 +254,7 @@ void getFiresStatsInFire(Store<AppState> store, FireNotification notif) {
}
void unsubsViaApi(Store<AppState> store, ObjectId id, onUnsubs) {
api.unsubscribe(store.state, id.toHexString()).then((res) {
api.unsubscribe(store.state, id.hexString).then((res) {
onUnsubs();
persistYourLocations(store.state.yourLocations);
});
@ -260,9 +263,9 @@ void unsubsViaApi(Store<AppState> store, ObjectId id, onUnsubs) {
void subscribeViaApi(Store<AppState> store, YourLocation loc, onSubs) {
api.subscribe(store.state, loc).then((subsId) {
YourLocation sub = loc;
if (loc.id != subsId) {
sub.id = new ObjectId.fromHexString(subsId);
}
// if (loc.id != subsId) {
sub.id = objectIdFromJson(subsId);
// }
onSubs(sub);
persistYourLocations(store.state.yourLocations);
});