Compare commits
No commits in common. "7b358a84efae38bb77dcd89c4c467312a47ded42" and "87b07b2df5883356325369aea96349b16c59d8bf" have entirely different histories.
7b358a84ef
...
87b07b2df5
2 changed files with 1 additions and 31 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
|
@ -33,12 +33,6 @@ class _ScambioDatiScreenState extends State<ScambioDatiScreen> with SingleTicker
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
// 🧹 AVVIO DEL NETTURBINO (con 10% di probabilità per non intasare il server)
|
|
||||||
if (Random().nextInt(10) == 0) {
|
|
||||||
_pulisciVecchieSessioni();
|
|
||||||
}
|
|
||||||
// RIMOZIONE DELLA SECONDA CHIAMATA LIBERA
|
|
||||||
|
|
||||||
// LOGICA DI APERTURA INTELLIGENTE:
|
// LOGICA DI APERTURA INTELLIGENTE:
|
||||||
// Lato A -> Inizia con la Fotocamera (Indice 1)
|
// Lato A -> Inizia con la Fotocamera (Indice 1)
|
||||||
// Lato B -> Inizia mostrando il QR (Indice 0)
|
// Lato B -> Inizia mostrando il QR (Indice 0)
|
||||||
|
|
@ -50,29 +44,6 @@ class _ScambioDatiScreenState extends State<ScambioDatiScreen> with SingleTicker
|
||||||
_avviaHost();
|
_avviaHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 🧹 IL NETTURBINO (GARBAGE COLLECTOR) ---
|
|
||||||
// Cerca nel database le sessioni più vecchie di 2 ore e le distrugge
|
|
||||||
Future<void> _pulisciVecchieSessioni() async {
|
|
||||||
try {
|
|
||||||
final dueOreFa = DateTime.now().subtract(const Duration(hours: 2));
|
|
||||||
|
|
||||||
final snapshot = await FirebaseFirestore.instance
|
|
||||||
.collection('scambi_cid')
|
|
||||||
.where('timestamp_scambio', isLessThan: Timestamp.fromDate(dueOreFa))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
int cancellati = 0;
|
|
||||||
for (var doc in snapshot.docs) {
|
|
||||||
await doc.reference.delete();
|
|
||||||
cancellati++;
|
|
||||||
}
|
|
||||||
|
|
||||||
debugPrint("🧹 [NETTURBINO] Pulizia completata: eliminate $cancellati sessioni vecchie.");
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint("⚠️ [NETTURBINO] Errore durante la pulizia: $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// Cancello la sessione se esco senza concludere, a meno che non sia l'ID della firma
|
// Cancello la sessione se esco senza concludere, a meno che non sia l'ID della firma
|
||||||
|
|
@ -471,4 +442,3 @@ class _ScambioDatiScreenState extends State<ScambioDatiScreen> with SingleTicker
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Test di sincronizzazione forzata ore 22:40
|
|
||||||
Loading…
Reference in a new issue