mirror of
https://github.com/immich-app/immich.git
synced 2025-11-19 01:52:39 +09:00
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker / pre-job (push) Waiting to run
Docker / Re-Tag ML () (push) Blocked by required conditions
Docker / Re-Tag ML (-armnn) (push) Blocked by required conditions
Docker / Re-Tag ML (-cuda) (push) Blocked by required conditions
Docker / Re-Tag ML (-openvino) (push) Blocked by required conditions
Docker / Re-Tag ML (-rknn) (push) Blocked by required conditions
Docker / Re-Tag ML (-rocm) (push) Blocked by required conditions
Docker / Re-Tag Server () (push) Blocked by required conditions
Docker / Build and Push ML (armnn, linux/arm64, -armnn) (push) Blocked by required conditions
Docker / Build and Push ML (cpu, ) (push) Blocked by required conditions
Docker / Build and Push ML (cuda, linux/amd64, -cuda) (push) Blocked by required conditions
Docker / Build and Push ML (openvino, linux/amd64, -openvino) (push) Blocked by required conditions
Docker / Build and Push ML (rknn, linux/arm64, -rknn) (push) Blocked by required conditions
Docker / Build and Push ML (rocm, linux/amd64, {"linux/amd64": "mich"}, -rocm) (push) Blocked by required conditions
Docker / Build and Push Server (push) Blocked by required conditions
Docker / Docker Build & Push Server Success (push) Blocked by required conditions
Docker / Docker Build & Push ML Success (push) Blocked by required conditions
Docs build / pre-job (push) Waiting to run
Docs build / Docs Build (push) Blocked by required conditions
Static Code Analysis / pre-job (push) Waiting to run
Static Code Analysis / Run Dart Code Analysis (push) Blocked by required conditions
Static Code Analysis / zizmor (push) Waiting to run
Test / pre-job (push) Waiting to run
Test / Test & Lint Server (push) Blocked by required conditions
Test / Unit Test CLI (push) Blocked by required conditions
Test / Unit Test CLI (Windows) (push) Blocked by required conditions
Test / Lint Web (push) Blocked by required conditions
Test / Test Web (push) Blocked by required conditions
Test / Test i18n (push) Blocked by required conditions
Test / End-to-End Lint (push) Blocked by required conditions
Test / Medium Tests (Server) (push) Blocked by required conditions
Test / End-to-End Tests (Server & CLI) (ubuntu-24.04-arm) (push) Blocked by required conditions
Test / End-to-End Tests (Server & CLI) (ubuntu-latest) (push) Blocked by required conditions
Test / End-to-End Tests (Web) (ubuntu-24.04-arm) (push) Blocked by required conditions
Test / End-to-End Tests (Web) (ubuntu-latest) (push) Blocked by required conditions
Test / End-to-End Tests Success (push) Blocked by required conditions
Test / Unit Test Mobile (push) Blocked by required conditions
Test / Unit Test ML (push) Blocked by required conditions
Test / .github Files Formatting (push) Blocked by required conditions
Test / ShellCheck (push) Waiting to run
Test / OpenAPI Clients (push) Waiting to run
Test / SQL Schema Checks (push) Waiting to run
* do not migrate again on app start * migrate backup albums over to sqlite --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
143 lines
4.8 KiB
Dart
143 lines
4.8 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
import 'package:immich_mobile/providers/album/album.provider.dart';
|
|
import 'package:immich_mobile/providers/asset.provider.dart';
|
|
import 'package:immich_mobile/providers/background_sync.provider.dart';
|
|
import 'package:immich_mobile/providers/gallery_permission.provider.dart';
|
|
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
|
import 'package:immich_mobile/providers/websocket.provider.dart';
|
|
import 'package:immich_mobile/routing/router.dart';
|
|
import 'package:immich_mobile/utils/migration.dart';
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
@RoutePage()
|
|
class ChangeExperiencePage extends ConsumerStatefulWidget {
|
|
final bool switchingToBeta;
|
|
|
|
const ChangeExperiencePage({super.key, required this.switchingToBeta});
|
|
|
|
@override
|
|
ConsumerState createState() => _ChangeExperiencePageState();
|
|
}
|
|
|
|
class _ChangeExperiencePageState extends ConsumerState<ChangeExperiencePage> {
|
|
bool hasMigrated = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => _handleMigration());
|
|
}
|
|
|
|
Future<void> _handleMigration() async {
|
|
if (widget.switchingToBeta) {
|
|
final assetNotifier = ref.read(assetProvider.notifier);
|
|
if (assetNotifier.mounted) {
|
|
assetNotifier.dispose();
|
|
}
|
|
final albumNotifier = ref.read(albumProvider.notifier);
|
|
if (albumNotifier.mounted) {
|
|
albumNotifier.dispose();
|
|
}
|
|
|
|
ref.read(websocketProvider.notifier).stopListenToOldEvents();
|
|
ref.read(websocketProvider.notifier).startListeningToBetaEvents();
|
|
|
|
final permission = await ref
|
|
.read(galleryPermissionNotifier.notifier)
|
|
.requestGalleryPermission();
|
|
|
|
if (permission.isGranted) {
|
|
await ref.read(backgroundSyncProvider).syncLocal(full: true);
|
|
await migrateDeviceAssetToSqlite(
|
|
ref.read(isarProvider),
|
|
ref.read(driftProvider),
|
|
);
|
|
await migrateBackupAlbumsToSqlite(
|
|
ref.read(isarProvider),
|
|
ref.read(driftProvider),
|
|
);
|
|
}
|
|
} else {
|
|
await ref.read(backgroundSyncProvider).cancel();
|
|
ref.read(websocketProvider.notifier).stopListeningToBetaEvents();
|
|
ref.read(websocketProvider.notifier).startListeningToOldEvents();
|
|
}
|
|
|
|
if (mounted) {
|
|
setState(() {
|
|
HapticFeedback.heavyImpact();
|
|
hasMigrated = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
AnimatedSwitcher(
|
|
duration: Durations.long4,
|
|
child: hasMigrated
|
|
? const Icon(
|
|
Icons.check_circle_rounded,
|
|
color: Colors.green,
|
|
size: 48.0,
|
|
)
|
|
: const SizedBox(
|
|
width: 50.0,
|
|
height: 50.0,
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
),
|
|
const SizedBox(height: 16.0),
|
|
Center(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
width: 300.0,
|
|
child: AnimatedSwitcher(
|
|
duration: Durations.long4,
|
|
child: hasMigrated
|
|
? Text(
|
|
"Migration success!",
|
|
style: context.textTheme.titleMedium,
|
|
textAlign: TextAlign.center,
|
|
)
|
|
: Text(
|
|
"Data migration in progress...\nPlease wait and don't close this page",
|
|
style: context.textTheme.titleMedium,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
if (hasMigrated)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 16.0),
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
context.replaceRoute(
|
|
widget.switchingToBeta
|
|
? const TabShellRoute()
|
|
: const TabControllerRoute(),
|
|
);
|
|
},
|
|
child: const Text("Continue"),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|