calendar sync fixes
This commit is contained in:
parent
010867260c
commit
7ebc470a7b
@ -136,7 +136,7 @@ Future<Database> initDB(DatabaseProvider database) async {
|
|||||||
// v5 shit
|
// v5 shit
|
||||||
"roundings": "{}",
|
"roundings": "{}",
|
||||||
"grade_rarities": "{}",
|
"grade_rarities": "{}",
|
||||||
"linked_accounts": "{}",
|
"linked_accounts": "[]",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print("ERROR: migrateDB: $error");
|
print("ERROR: migrateDB: $error");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:refilc/models/linked_account.dart';
|
||||||
import 'package:refilc/models/self_note.dart';
|
import 'package:refilc/models/self_note.dart';
|
||||||
import 'package:refilc/models/subject_lesson_count.dart';
|
import 'package:refilc/models/subject_lesson_count.dart';
|
||||||
import 'package:refilc_kreta_api/models/week.dart';
|
import 'package:refilc_kreta_api/models/week.dart';
|
||||||
@ -208,4 +209,11 @@ class UserDatabaseStore {
|
|||||||
await db.update("user_data", {"grade_rarities": raritiesJson},
|
await db.update("user_data", {"grade_rarities": raritiesJson},
|
||||||
where: "id = ?", whereArgs: [userId]);
|
where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> storeLinkedAccounts(List<LinkedAccount> accounts,
|
||||||
|
{required String userId}) async {
|
||||||
|
String accountsJson = jsonEncode(accounts.map((e) => e.json).toList());
|
||||||
|
await db.update("user_data", {"linked_accounts": accountsJson},
|
||||||
|
where: "id = ?", whereArgs: [userId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,14 @@ class LinkedAccount {
|
|||||||
String username;
|
String username;
|
||||||
String displayName;
|
String displayName;
|
||||||
String id;
|
String id;
|
||||||
|
Map? json;
|
||||||
|
|
||||||
LinkedAccount({
|
LinkedAccount({
|
||||||
required this.type,
|
required this.type,
|
||||||
required this.username,
|
required this.username,
|
||||||
required this.displayName,
|
required this.displayName,
|
||||||
required this.id,
|
required this.id,
|
||||||
|
required this.json,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory LinkedAccount.fromJson(Map json) {
|
factory LinkedAccount.fromJson(Map json) {
|
||||||
@ -30,6 +32,7 @@ class LinkedAccount {
|
|||||||
username: json['username'],
|
username: json['username'],
|
||||||
displayName: json['display_name'],
|
displayName: json['display_name'],
|
||||||
id: json['id'],
|
id: json['id'],
|
||||||
|
json: json,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ class ThirdPartyProvider with ChangeNotifier {
|
|||||||
}) {
|
}) {
|
||||||
_context = context;
|
_context = context;
|
||||||
_linkedAccounts = initialLinkedAccounts ?? [];
|
_linkedAccounts = initialLinkedAccounts ?? [];
|
||||||
|
|
||||||
|
if (_linkedAccounts.isEmpty) restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> restore() async {
|
Future<void> restore() async {
|
||||||
@ -56,12 +58,12 @@ class ThirdPartyProvider with ChangeNotifier {
|
|||||||
if (!await _googleSignIn.isSignedIn()) {
|
if (!await _googleSignIn.isSignedIn()) {
|
||||||
GoogleSignInAccount? account = await _googleSignIn.signIn();
|
GoogleSignInAccount? account = await _googleSignIn.signIn();
|
||||||
|
|
||||||
LinkedAccount linked = LinkedAccount(
|
LinkedAccount linked = LinkedAccount.fromJson({
|
||||||
type: AccountType.google,
|
'type': 'google',
|
||||||
username: account?.email ?? '',
|
'username': account?.email ?? '',
|
||||||
displayName: account?.displayName ?? '',
|
'display_name': account?.displayName ?? '',
|
||||||
id: account?.id ?? '',
|
'id': account?.id ?? ''
|
||||||
);
|
});
|
||||||
_linkedAccounts.add(linked);
|
_linkedAccounts.add(linked);
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user