mirror of
https://github.com/immich-app/immich.git
synced 2026-02-21 16:20:34 +09:00
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docker / pre-job (push) Has been cancelled
Docker / Re-Tag ML () (push) Has been cancelled
Docker / Re-Tag ML (-armnn) (push) Has been cancelled
Docker / Re-Tag ML (-cuda) (push) Has been cancelled
Docker / Re-Tag ML (-openvino) (push) Has been cancelled
Docker / Re-Tag ML (-rknn) (push) Has been cancelled
Docker / Re-Tag ML (-rocm) (push) Has been cancelled
Docker / Re-Tag Server () (push) Has been cancelled
Docker / Build and Push ML (armnn, linux/arm64, -armnn) (push) Has been cancelled
Docker / Build and Push ML (cpu) (push) Has been cancelled
Docker / Build and Push ML (cuda, linux/amd64, -cuda) (push) Has been cancelled
Docker / Build and Push ML (openvino, linux/amd64, -openvino) (push) Has been cancelled
Docker / Build and Push ML (rknn, linux/arm64, -rknn) (push) Has been cancelled
Docker / Build and Push ML (rocm, linux/amd64, {"linux/amd64": "mich"}, -rocm) (push) Has been cancelled
Docker / Build and Push Server (push) Has been cancelled
Docker / Docker Build & Push Server Success (push) Has been cancelled
Docker / Docker Build & Push ML Success (push) Has been cancelled
Docs build / pre-job (push) Has been cancelled
Docs build / Docs Build (push) Has been cancelled
Zizmor / Zizmor (push) Has been cancelled
Manage release PR / bump (push) Has been cancelled
Static Code Analysis / pre-job (push) Has been cancelled
Static Code Analysis / Run Dart Code Analysis (push) Has been cancelled
Test / pre-job (push) Has been cancelled
Test / Test & Lint Server (push) Has been cancelled
Test / Unit Test CLI (push) Has been cancelled
Test / Unit Test CLI (Windows) (push) Has been cancelled
Test / Lint Web (push) Has been cancelled
Test / Test Web (push) Has been cancelled
Test / Test i18n (push) Has been cancelled
Test / End-to-End Lint (push) Has been cancelled
Test / Medium Tests (Server) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (ubuntu-24.04-arm) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (ubuntu-latest) (push) Has been cancelled
Test / End-to-End Tests (Web) (ubuntu-24.04-arm) (push) Has been cancelled
Test / End-to-End Tests (Web) (ubuntu-latest) (push) Has been cancelled
Test / End-to-End Tests Success (push) Has been cancelled
Test / Unit Test Mobile (push) Has been cancelled
Test / Unit Test ML (push) Has been cancelled
Test / .github Files Formatting (push) Has been cancelled
Test / ShellCheck (push) Has been cancelled
Test / OpenAPI Clients (push) Has been cancelled
Test / SQL Schema Checks (push) Has been cancelled
* fix: image and video download complete notification shows "file_name" * fix lint --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
114 lines
4.4 KiB
Dart
114 lines
4.4 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:background_downloader/background_downloader.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:immich_mobile/constants/constants.dart';
|
|
import 'package:immich_mobile/domain/models/store.model.dart';
|
|
import 'package:immich_mobile/domain/services/log.service.dart';
|
|
import 'package:immich_mobile/domain/services/store.service.dart';
|
|
import 'package:immich_mobile/entities/album.entity.dart';
|
|
import 'package:immich_mobile/entities/android_device_asset.entity.dart';
|
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
|
import 'package:immich_mobile/entities/backup_album.entity.dart';
|
|
import 'package:immich_mobile/entities/duplicated_asset.entity.dart';
|
|
import 'package:immich_mobile/entities/etag.entity.dart';
|
|
import 'package:immich_mobile/entities/ios_device_asset.entity.dart';
|
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/device_asset.entity.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/store.entity.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/log.repository.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/logger_db.repository.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/network.repository.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/store.repository.dart';
|
|
import 'package:isar/isar.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
void configureFileDownloaderNotifications() {
|
|
FileDownloader().configureNotificationForGroup(
|
|
kDownloadGroupImage,
|
|
running: TaskNotification('downloading_media'.t(), '${'file_name_text'.t()}: {filename}'),
|
|
complete: TaskNotification('download_finished'.t(), '${'file_name_text'.t()}: {filename}'),
|
|
progressBar: true,
|
|
);
|
|
|
|
FileDownloader().configureNotificationForGroup(
|
|
kDownloadGroupVideo,
|
|
running: TaskNotification('downloading_media'.t(), '${'file_name_text'.t()}: {filename}'),
|
|
complete: TaskNotification('download_finished'.t(), '${'file_name_text'.t()}: {filename}'),
|
|
progressBar: true,
|
|
);
|
|
|
|
FileDownloader().configureNotificationForGroup(
|
|
kManualUploadGroup,
|
|
running: TaskNotification('uploading_media'.t(), 'backup_background_service_in_progress_notification'.t()),
|
|
complete: TaskNotification('upload_finished'.t(), 'backup_background_service_complete_notification'.t()),
|
|
groupNotificationId: kManualUploadGroup,
|
|
);
|
|
|
|
FileDownloader().configureNotificationForGroup(
|
|
kBackupGroup,
|
|
running: TaskNotification('uploading_media'.t(), 'backup_background_service_in_progress_notification'.t()),
|
|
complete: TaskNotification('upload_finished'.t(), 'backup_background_service_complete_notification'.t()),
|
|
groupNotificationId: kBackupGroup,
|
|
);
|
|
}
|
|
|
|
abstract final class Bootstrap {
|
|
static Future<(Isar isar, Drift drift, DriftLogger logDb)> initDB() async {
|
|
final drift = Drift();
|
|
final logDb = DriftLogger();
|
|
|
|
Isar? isar = Isar.getInstance();
|
|
|
|
if (isar != null) {
|
|
return (isar, drift, logDb);
|
|
}
|
|
|
|
final dir = await getApplicationDocumentsDirectory();
|
|
isar = await Isar.open(
|
|
[
|
|
StoreValueSchema,
|
|
AssetSchema,
|
|
AlbumSchema,
|
|
ExifInfoSchema,
|
|
UserSchema,
|
|
BackupAlbumSchema,
|
|
DuplicatedAssetSchema,
|
|
ETagSchema,
|
|
if (Platform.isAndroid) AndroidDeviceAssetSchema,
|
|
if (Platform.isIOS) IOSDeviceAssetSchema,
|
|
DeviceAssetEntitySchema,
|
|
],
|
|
directory: dir.path,
|
|
maxSizeMiB: 2048,
|
|
inspector: kDebugMode,
|
|
);
|
|
|
|
return (isar, drift, logDb);
|
|
}
|
|
|
|
static Future<void> initDomain(
|
|
Isar db,
|
|
Drift drift,
|
|
DriftLogger logDb, {
|
|
bool listenStoreUpdates = true,
|
|
bool shouldBufferLogs = true,
|
|
}) async {
|
|
final isBeta = await IsarStoreRepository(db).tryGet(StoreKey.betaTimeline) ?? true;
|
|
final IStoreRepository storeRepo = isBeta ? DriftStoreRepository(drift) : IsarStoreRepository(db);
|
|
|
|
await StoreService.init(storeRepository: storeRepo, listenUpdates: listenStoreUpdates);
|
|
|
|
await LogService.init(
|
|
logRepository: LogRepository(logDb),
|
|
storeRepository: storeRepo,
|
|
shouldBuffer: shouldBufferLogs,
|
|
);
|
|
|
|
await NetworkRepository.init();
|
|
}
|
|
}
|