After a long time, No idea whats changed
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart' as K;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tasktracker/NewProject.dart';
|
||||
@@ -19,7 +20,7 @@ import 'package:sqflite_common/sqlite_api.dart';
|
||||
import 'Tasks.dart';
|
||||
import 'Dialogs.dart';
|
||||
|
||||
bool cacheEnabled = true;
|
||||
bool cacheEnabled = !K.kIsWeb;
|
||||
|
||||
late http.Response loginResponse;
|
||||
|
||||
@@ -63,15 +64,16 @@ Future<http.Response> login(String _username, String password) async {
|
||||
Future<void> initUserData() async {
|
||||
if (cacheEnabled) {
|
||||
await initCacheDatabase();
|
||||
int catCount = Sqflite.firstIntValue(await cacheDb.rawQuery('SELECT COUNT(*) FROM Categories')) ?? 0;
|
||||
int taskCount = Sqflite.firstIntValue(await cacheDb.rawQuery('SELECT COUNT(*) FROM TaskTypes')) ?? 0;
|
||||
if(catCount > 0 && taskCount > 0){
|
||||
await refreshUserData(forceOffline: true);
|
||||
refreshUserData();
|
||||
}else{
|
||||
await refreshUserData();
|
||||
}
|
||||
}
|
||||
int catCount = Sqflite.firstIntValue(await cacheDb.rawQuery('SELECT COUNT(*) FROM Categories')) ?? 0;
|
||||
int taskCount = Sqflite.firstIntValue(await cacheDb.rawQuery('SELECT COUNT(*) FROM TaskTypes')) ?? 0;
|
||||
if(catCount > 0 && taskCount > 0){
|
||||
await refreshUserData(forceOffline: true);
|
||||
refreshUserData();
|
||||
}else{
|
||||
await refreshUserData();
|
||||
}
|
||||
|
||||
|
||||
BuildBridgeToServer();
|
||||
Debug.Log('Initializing UserData...');
|
||||
@@ -156,7 +158,7 @@ Future<void> refreshUserData({bool forceOffline = false}) async {
|
||||
|
||||
refreshStream.add(false);
|
||||
} else {
|
||||
if(false) {
|
||||
if(K.kIsWeb) {
|
||||
Debug.LogTest('updating cats ${DateTime.now()}');
|
||||
categories = await GetCategories(false);
|
||||
Debug.LogTest('updating projs ${DateTime.now()}');
|
||||
@@ -197,12 +199,13 @@ Future<void> refreshUserData({bool forceOffline = false}) async {
|
||||
|
||||
Debug.LogTest('Done filling @ ${DateTime.now()}');
|
||||
|
||||
categories = await GetCategories(true);
|
||||
projects = await GetProjects(true);
|
||||
taskTypes = await GetTaskTypes(true);
|
||||
activities = await GetActivities(true);
|
||||
journal = await GetJournals(true);
|
||||
todos = await GetTodos(true);
|
||||
|
||||
categories = await GetCategories(true);
|
||||
projects = await GetProjects(true);
|
||||
taskTypes = await GetTaskTypes(true);
|
||||
activities = await GetActivities(true);
|
||||
journal = await GetJournals(true);
|
||||
todos = await GetTodos(true);
|
||||
|
||||
|
||||
} catch (e) {
|
||||
@@ -220,7 +223,7 @@ Future<void> refreshUserData({bool forceOffline = false}) async {
|
||||
}
|
||||
|
||||
Future<bool> cacheDbExist() async {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
if (!K.kIsWeb && Platform.isAndroid || Platform.isIOS) {
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
return databaseFactory.databaseExists(directory.path + 'cache.db');
|
||||
} else {
|
||||
@@ -248,7 +251,7 @@ Future<void> updateProjectsList() async {
|
||||
Future<void> initCacheDatabase() async {
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
Debug.LogResponse('database at ' + directory.path + '/cache.db');
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
if (!K.kIsWeb && Platform.isAndroid || Platform.isIOS) {
|
||||
cacheDb = await openDatabase(directory.path + 'cache.db', version: 1, onCreate: onCacheDatabaseCreate, onUpgrade: onCacheDatabaseUpgrade);
|
||||
} else {
|
||||
cacheDb = await SqlFF.databaseFactoryFfi
|
||||
|
||||
Reference in New Issue
Block a user