Syncing issue fixed, Bridge established to server
This commit is contained in:
@@ -21,7 +21,6 @@ import 'Tasks.dart';
|
||||
import 'Activities.dart';
|
||||
import 'User.dart' as User;
|
||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'Dialogs.dart';
|
||||
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
|
||||
showAlertDialog(BuildContext context, String title, String message) {
|
||||
@@ -148,6 +147,7 @@ class MyHomePage extends StatefulWidget {
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
var connectivitySub;
|
||||
var refreshSub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -157,28 +157,33 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
super.initState();
|
||||
print("Initializing refresh stream on main dart");
|
||||
|
||||
connectivitySub=Connectivity().onConnectivityChanged.listen((result) {
|
||||
if (this.mounted) {
|
||||
setState(() {});
|
||||
// connectivitySub=Connectivity().onConnectivityChanged.listen((result) {
|
||||
// if (this.mounted) {
|
||||
// setState(() {});
|
||||
// }
|
||||
// });
|
||||
refreshSub = User.refreshStream.stream.listen((event) {
|
||||
if(event==false){
|
||||
//Update done, Lets go update data
|
||||
LoadStats();
|
||||
}
|
||||
});
|
||||
LoadStats();
|
||||
// User.progressDialog=progressDialog;
|
||||
}
|
||||
var refreshSub;
|
||||
void init(BuildContext context) async{
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
refreshSub = User.refreshStream.stream.listen((value) {
|
||||
print("Streaming refresh : $value");
|
||||
if(value){
|
||||
Dialogs.waiting("Syncing...");
|
||||
// Dialogs.waiting("Syncing...");
|
||||
print("Opening progress dialog");
|
||||
}else{
|
||||
Dialogs.hide();
|
||||
// Dialogs.hide();
|
||||
print("Closing progress dialog");
|
||||
}
|
||||
});
|
||||
await User.refreshUserData();
|
||||
//await User.refreshUserData();
|
||||
|
||||
}
|
||||
DateTime? lastProductive = null;
|
||||
@@ -187,6 +192,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
connectivitySub?.cancel();
|
||||
refreshSub?.closeSteam();
|
||||
}
|
||||
void LoadStats() async {
|
||||
// return;
|
||||
@@ -348,7 +354,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
return Scaffold(
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => NewActivity())).then((value) => {User.refreshUserData().then((va) => LoadStats())});
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => NewActivity()));
|
||||
},
|
||||
label: Text("New Activity"),
|
||||
icon: Icon(Icons.add)),
|
||||
@@ -369,7 +375,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
: InkWell(
|
||||
onTap: () {
|
||||
setState(() async {
|
||||
await User.refreshUserData();
|
||||
//await User.refreshUserData();
|
||||
LoadStats();
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user