diff --git a/auth/lib/main.dart b/auth/lib/main.dart index e837892f8cb..c747ac41eb4 100644 --- a/auth/lib/main.dart +++ b/auth/lib/main.dart @@ -104,7 +104,12 @@ Future _runInForeground() async { final savedThemeMode = _themeMode(await AdaptiveTheme.getThemeMode()); return await _runWithLogs(() async { _logger.info("Starting app in foreground"); - await _init(false, via: 'mainMethod'); + try { + await _init(false, via: 'mainMethod'); + } catch (e, s) { + _logger.severe("Failed to init", e, s); + rethrow; + } final Locale? locale = await getLocale(noFallback: true); unawaited(UpdateService.instance.showUpdateNotification()); runApp( @@ -156,7 +161,7 @@ void _registerWindowsProtocol() { Future _init(bool bool, {String? via}) async { _registerWindowsProtocol(); - await initCryptoUtil(); + await CryptoUtil.init(); await PreferenceService.instance.init(); await CodeStore.instance.init(); diff --git a/auth/lib/services/window_listener_service.dart b/auth/lib/services/window_listener_service.dart index 261b56f457d..73f431116f0 100644 --- a/auth/lib/services/window_listener_service.dart +++ b/auth/lib/services/window_listener_service.dart @@ -1,11 +1,12 @@ import 'dart:async'; import 'dart:ui'; +import 'package:flutter/widgets.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:window_manager/window_manager.dart'; class WindowListenerService { - static const double minWindowHeight = 600.0; + static const double minWindowHeight = 320.0; static const double minWindowWidth = 800.0; static const double maxWindowHeight = 8192.0; static const double maxWindowWidth = 8192.0; @@ -25,21 +26,16 @@ class WindowListenerService { _preferences.getDouble('windowWidth') ?? minWindowWidth; final double windowHeight = _preferences.getDouble('windowHeight') ?? minWindowHeight; - return Size( - windowWidth.clamp(minWindowWidth, maxWindowWidth), - windowHeight.clamp(minWindowHeight, maxWindowHeight), - ); + final w = windowWidth.clamp(200.0, maxWindowWidth); + final h = windowHeight.clamp(400.0, maxWindowHeight); + return Size(w, h); } Future onWindowResize() async { + final width = (await windowManager.getSize()).width; + final height = (await windowManager.getSize()).height; // Save the window size to shared preferences - await _preferences.setDouble( - 'windowWidth', - (await windowManager.getSize()).width, - ); - await _preferences.setDouble( - 'windowHeight', - (await windowManager.getSize()).height, - ); + await _preferences.setDouble('windowWidth', width); + await _preferences.setDouble('windowHeight', height); } }