more refactors

This commit is contained in:
shenlong-tanwen
2024-10-20 16:50:34 +05:30
parent 7ea21d636f
commit 8f47645cdb
35 changed files with 399 additions and 83 deletions
+1 -2
View File
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
const String kImmichAppName = "Immich";
/// Log messages stored in the DB
const int kLogMessageLimit = 500;
@@ -13,6 +11,7 @@ const String kCacheThumbnailsKey = 'ImThumbnailCacheKey';
const int kCacheMaxNrOfThumbnails = 500;
/// Grid constants
const double kGridAutoHideAppBarOffset = 30;
const int kGridThumbnailSize = 200;
const int kGridThumbnailQuality = 80;
@@ -9,3 +9,9 @@ class SizeConstants {
static const l = 32.0;
static const xl = 64.0;
}
class BodyRatioConstants {
const BodyRatioConstants._();
static const oneThird = 1 / 3;
}
@@ -17,6 +17,9 @@ extension BuildContextHelper on BuildContext {
/// Get the [Size] of [MediaQuery]
Size get mediaQuerySize => MediaQuery.sizeOf(this);
/// Get the [Padding] of [MediaQuery]
EdgeInsets get mediaQueryPadding => MediaQuery.paddingOf(this);
/// Get the [EdgeInsets] of [MediaQuery]
EdgeInsets get viewInsets => MediaQuery.viewInsetsOf(this);
@@ -4,6 +4,7 @@ import 'package:device_info_plus/device_info_plus.dart';
import 'package:http/http.dart';
import 'package:immich_mobile/domain/interfaces/store.interface.dart';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/domain/services/login.service.dart';
import 'package:immich_mobile/presentation/router/router.dart';
import 'package:immich_mobile/service_locator.dart';
import 'package:immich_mobile/utils/constants/globals.dart';
@@ -57,6 +58,7 @@ class ImApiClient extends ApiClient with LogMixin {
if (res.statusCode == HttpStatus.unauthorized) {
log.e("Token invalid. Redirecting to login route");
await di<LoginService>().logout();
await di<AppRouter>().replaceAll([const LoginRoute()]);
throw ApiException(res.statusCode, "Unauthorized");
}
+2 -2
View File
@@ -69,12 +69,12 @@ class IsolateHelper {
BackgroundIsolateBinaryMessenger.ensureInitialized(token);
DartPluginRegistrant.ensureInitialized();
// Delay to ensure the isolate is ready
await Future.delayed(const Duration(milliseconds: 100));
await Future.delayed(Durations.short2);
helper.postIsolateHandling();
try {
final result = await computation();
// Delay to ensure the isolate is not killed prematurely
await Future.delayed(const Duration(milliseconds: 100));
await Future.delayed(Durations.short2);
return result;
} finally {
// Always close the new database connection on Isolate end