Skip to content

Commit

Permalink
[auth] Minor fixes (#4797)
Browse files Browse the repository at this point in the history
## Description

## Tests
  • Loading branch information
ua741 authored Jan 21, 2025
2 parents dd600c0 + 6c68052 commit 17ab295
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
9 changes: 7 additions & 2 deletions auth/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ Future<void> _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(
Expand Down Expand Up @@ -156,7 +161,7 @@ void _registerWindowsProtocol() {

Future<void> _init(bool bool, {String? via}) async {
_registerWindowsProtocol();
await initCryptoUtil();
await CryptoUtil.init();

await PreferenceService.instance.init();
await CodeStore.instance.init();
Expand Down
22 changes: 9 additions & 13 deletions auth/lib/services/window_listener_service.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<void> 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);
}
}

0 comments on commit 17ab295

Please sign in to comment.