refactor repositories
This commit is contained in:
@@ -37,7 +37,7 @@ class _ImSwitchListTileState<T> extends State<ImSwitchListTile<T>> {
|
||||
|
||||
final value = T != bool ? widget.toAppSetting!(enabled) : enabled as T;
|
||||
if (value != null &&
|
||||
await _appSettingService.setSetting(widget.setting, value) &&
|
||||
await _appSettingService.upsert(widget.setting, value) &&
|
||||
context.mounted) {
|
||||
setState(() {
|
||||
isEnabled = enabled;
|
||||
@@ -48,7 +48,7 @@ class _ImSwitchListTileState<T> extends State<ImSwitchListTile<T>> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_appSettingService.getSetting(widget.setting).then((value) {
|
||||
_appSettingService.get(widget.setting).then((value) {
|
||||
if (context.mounted) {
|
||||
setState(() {
|
||||
isEnabled = T != bool ? widget.fromAppSetting!(value) : value as bool;
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/asset.interface.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/renderlist.interface.dart';
|
||||
import 'package:immich_mobile/presentation/components/grid/immich_asset_grid.state.dart';
|
||||
import 'package:immich_mobile/presentation/components/grid/immich_asset_grid.widget.dart';
|
||||
import 'package:immich_mobile/service_locator.dart';
|
||||
@@ -15,8 +16,8 @@ class HomePage extends StatelessWidget {
|
||||
return Scaffold(
|
||||
body: BlocProvider(
|
||||
create: (_) => ImmichAssetGridCubit(
|
||||
renderStream: di<IAssetRepository>().watchRenderList(),
|
||||
assetProvider: di<IAssetRepository>().fetchAssets,
|
||||
renderStream: di<IRenderListRepository>().watchAll(),
|
||||
assetProvider: di<IAssetRepository>().getAll,
|
||||
),
|
||||
child: const ImAssetGrid(),
|
||||
),
|
||||
|
||||
@@ -65,7 +65,7 @@ class LoginPageCubit extends Cubit<LoginPageState> with LogMixin {
|
||||
// Check for /.well-known/immich
|
||||
url = await loginService.resolveEndpoint(uri);
|
||||
|
||||
di<IStoreRepository>().set(StoreKey.serverEndpoint, url);
|
||||
di<IStoreRepository>().upsert(StoreKey.serverEndpoint, url);
|
||||
ServiceLocator.registerApiClient(url);
|
||||
ServiceLocator.registerPostValidationServices();
|
||||
ServiceLocator.registerPostGlobalStates();
|
||||
@@ -123,7 +123,7 @@ class LoginPageCubit extends Cubit<LoginPageState> with LogMixin {
|
||||
}
|
||||
|
||||
Future<void> _postLogin(String accessToken) async {
|
||||
await di<IStoreRepository>().set(StoreKey.accessToken, accessToken);
|
||||
await di<IStoreRepository>().upsert(StoreKey.accessToken, accessToken);
|
||||
|
||||
/// Set token to interceptor
|
||||
await di<ImmichApiClient>().init(accessToken: accessToken);
|
||||
@@ -136,10 +136,10 @@ class LoginPageCubit extends Cubit<LoginPageState> with LogMixin {
|
||||
|
||||
// Register user
|
||||
ServiceLocator.registerCurrentUser(user);
|
||||
await di<IUserRepository>().add(user);
|
||||
await di<IUserRepository>().upsert(user);
|
||||
// Remove and Sync assets in background
|
||||
await di<IAssetRepository>().clearAll();
|
||||
unawaited(di<AssetSyncService>().doFullRemoteSyncForUserDrift(user));
|
||||
await di<IAssetRepository>().deleteAll();
|
||||
unawaited(di<AssetSyncService>().performFullRemoteSyncForUser(user));
|
||||
|
||||
emit(state.copyWith(
|
||||
isValidationInProgress: false,
|
||||
|
||||
@@ -10,9 +10,8 @@ class AppThemeCubit extends Cubit<AppTheme> {
|
||||
late final StreamSubscription _appSettingSubscription;
|
||||
|
||||
AppThemeCubit(this._appSettings) : super(AppTheme.blue) {
|
||||
_appSettingSubscription = _appSettings
|
||||
.watchSetting(AppSetting.appTheme)
|
||||
.listen((theme) => emit(theme));
|
||||
_appSettingSubscription =
|
||||
_appSettings.watch(AppSetting.appTheme).listen((theme) => emit(theme));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -3,8 +3,10 @@ import 'dart:async';
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:immich_mobile/domain/services/asset_sync.service.dart';
|
||||
import 'package:immich_mobile/domain/services/login.service.dart';
|
||||
import 'package:immich_mobile/presentation/components/image/immich_logo.widget.dart';
|
||||
import 'package:immich_mobile/presentation/modules/common/states/current_user.state.dart';
|
||||
import 'package:immich_mobile/presentation/modules/login/states/login_page.state.dart';
|
||||
import 'package:immich_mobile/presentation/router/router.dart';
|
||||
import 'package:immich_mobile/service_locator.dart';
|
||||
@@ -49,7 +51,9 @@ class _SplashScreenState extends State<SplashScreenPage>
|
||||
}
|
||||
|
||||
Future<void> _tryLogin() async {
|
||||
if (await di<LoginService>().tryLoginFromSplash() && mounted) {
|
||||
if (await di<LoginService>().tryAutoLogin() && mounted) {
|
||||
unawaited(di<AssetSyncService>()
|
||||
.performFullRemoteSyncForUser(di<CurrentUserCubit>().state));
|
||||
unawaited(context.replaceRoute(const TabControllerRoute()));
|
||||
} else {
|
||||
unawaited(context.replaceRoute(const LoginRoute()));
|
||||
|
||||
Reference in New Issue
Block a user