mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
desktop db migrate enabled
This commit is contained in:
parent
30635b05d5
commit
cd4408449c
2 changed files with 32 additions and 2 deletions
|
@ -157,7 +157,7 @@ void main() async {
|
|||
|
||||
await Hive.openBox<dynamic>(DB.boxNameDBInfo);
|
||||
|
||||
// todo: db migrate stuff for desktop needs to be handled eventually
|
||||
// Desktop migrate handled elsewhere (currently desktop_login_view.dart)
|
||||
if (!Util.isDesktop) {
|
||||
int dbVersion = DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNameDBInfo, key: "hive_data_version") as int? ??
|
||||
|
@ -172,7 +172,7 @@ void main() async {
|
|||
),
|
||||
);
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("Cannot migrate database\n$e $s",
|
||||
Logging.instance.log("Cannot migrate mobile database\n$e $s",
|
||||
level: LogLevel.Error, printFullLength: true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,17 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||
|
||||
import '../../hive/db.dart';
|
||||
import '../../utilities/db_version_migration.dart';
|
||||
import '../../utilities/logger.dart';
|
||||
|
||||
class DesktopLoginView extends ConsumerStatefulWidget {
|
||||
const DesktopLoginView({
|
||||
Key? key,
|
||||
|
@ -43,6 +48,25 @@ class _DesktopLoginViewState extends ConsumerState<DesktopLoginView> {
|
|||
bool hidePassword = true;
|
||||
bool _continueEnabled = false;
|
||||
|
||||
Future<void> _checkDesktopMigrate() async {
|
||||
if (Util.isDesktop) {
|
||||
int dbVersion = DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNameDBInfo, key: "hive_data_version") as int? ??
|
||||
0;
|
||||
if (dbVersion < Constants.currentHiveDbVersion) {
|
||||
try {
|
||||
await DbVersionMigrator().migrate(
|
||||
dbVersion,
|
||||
secureStore: ref.read(secureStoreProvider),
|
||||
);
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("Cannot migrate desktop database\n$e $s",
|
||||
level: LogLevel.Error, printFullLength: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> login() async {
|
||||
try {
|
||||
unawaited(
|
||||
|
@ -63,12 +87,18 @@ class _DesktopLoginViewState extends ConsumerState<DesktopLoginView> {
|
|||
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
|
||||
// init security context
|
||||
await ref
|
||||
.read(storageCryptoHandlerProvider)
|
||||
.initFromExisting(passwordController.text);
|
||||
|
||||
// init desktop secure storage
|
||||
await (ref.read(secureStoreProvider).store as DesktopSecureStore).init();
|
||||
|
||||
// check and migrate if needed
|
||||
await _checkDesktopMigrate();
|
||||
|
||||
// load data
|
||||
await widget.load?.call();
|
||||
|
||||
// if no errors passphrase is correct
|
||||
|
|
Loading…
Reference in a new issue