Finish KeyToken operations

This commit is contained in:
2025-04-18 18:56:17 +02:00
parent 1f0f280286
commit 78c895547e
23 changed files with 1089 additions and 211 deletions

View File

@@ -9,6 +9,7 @@ import 'package:hive_flutter/hive_flutter.dart';
import 'package:simplecloudnotifier/api/api_client.dart';
import 'package:simplecloudnotifier/models/channel.dart';
import 'package:simplecloudnotifier/models/client.dart';
import 'package:simplecloudnotifier/models/keytoken.dart';
import 'package:simplecloudnotifier/models/scn_message.dart';
import 'package:simplecloudnotifier/nav_layout.dart';
import 'package:simplecloudnotifier/pages/channel_view/channel_view.dart';
@@ -50,6 +51,7 @@ void main() async {
Hive.registerAdapter(SCNMessageAdapter());
Hive.registerAdapter(ChannelAdapter());
Hive.registerAdapter(FBMessageAdapter());
Hive.registerAdapter(KeyTokenAdapter());
print('[INIT] Load Hive<scn-logs>...');
@@ -106,6 +108,17 @@ void main() async {
ApplicationLog.writeRawFailure('Failed to open Hive-Box: scn-fb-messages', {'error': exc.toString(), 'trace': trace});
}
print('[INIT] Load Hive<scn-keytoken-value-cache>...');
try {
await Hive.openBox<KeyToken>('scn-keytoken-value-cache');
} catch (exc, trace) {
Hive.deleteBoxFromDisk('scn-keytoken-value-cache');
await Hive.openBox<KeyToken>('scn-keytoken-value-cache');
ApplicationLog.error('Failed to open Hive-Box: scn-keytoken-value-cache' + exc.toString(), trace: trace);
ApplicationLog.writeRawFailure('Failed to open Hive-Box: scn-keytoken-value-cache', {'error': exc.toString(), 'trace': trace});
}
print('[INIT] Load AppAuth...');
final appAuth = AppAuth(); // ensure UserAccount is loaded