Fix backup not resuming after closed and reopen (#266)

* Fixed app not resuming backup after closing and reopening the app

* Fixed cosmetic effect of backup button doesn't change state right away after pressing start backup

* Fixed grammar

* Fixed deep copy problem that cause incorrect asset count when backing up

* Format code
This commit is contained in:
Alex
2022-06-25 15:12:47 -05:00
committed by GitHub
parent d02b97e1c1
commit 40a8115101
63 changed files with 677 additions and 300 deletions

View File

@@ -149,7 +149,8 @@ class ImmichExif {
String toJson() => json.encode(toMap());
factory ImmichExif.fromJson(String source) => ImmichExif.fromMap(json.decode(source));
factory ImmichExif.fromJson(String source) =>
ImmichExif.fromMap(json.decode(source));
@override
String toString() {

View File

@@ -95,7 +95,8 @@ class ImmichAsset extends Equatable {
String toJson() => json.encode(toMap());
factory ImmichAsset.fromJson(String source) => ImmichAsset.fromMap(json.decode(source));
factory ImmichAsset.fromJson(String source) =>
ImmichAsset.fromMap(json.decode(source));
@override
String toString() {

View File

@@ -85,13 +85,15 @@ class ImmichAssetWithExif {
originalPath: map['originalPath'] ?? '',
isFavorite: map['isFavorite'] ?? false,
duration: map['duration'],
exifInfo: map['exifInfo'] != null ? ImmichExif.fromMap(map['exifInfo']) : null,
exifInfo:
map['exifInfo'] != null ? ImmichExif.fromMap(map['exifInfo']) : null,
);
}
String toJson() => json.encode(toMap());
factory ImmichAssetWithExif.fromJson(String source) => ImmichAssetWithExif.fromMap(json.decode(source));
factory ImmichAssetWithExif.fromJson(String source) =>
ImmichAssetWithExif.fromMap(json.decode(source));
@override
String toString() {

View File

@@ -34,16 +34,20 @@ class MapboxInfo {
String toJson() => json.encode(toMap());
factory MapboxInfo.fromJson(String source) => MapboxInfo.fromMap(json.decode(source));
factory MapboxInfo.fromJson(String source) =>
MapboxInfo.fromMap(json.decode(source));
@override
String toString() => 'MapboxInfo(isEnable: $isEnable, mapboxSecret: $mapboxSecret)';
String toString() =>
'MapboxInfo(isEnable: $isEnable, mapboxSecret: $mapboxSecret)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is MapboxInfo && other.isEnable == isEnable && other.mapboxSecret == mapboxSecret;
return other is MapboxInfo &&
other.isEnable == isEnable &&
other.mapboxSecret == mapboxSecret;
}
@override

View File

@@ -64,7 +64,8 @@ class ServerInfo {
String toJson() => json.encode(toMap());
factory ServerInfo.fromJson(String source) => ServerInfo.fromMap(json.decode(source));
factory ServerInfo.fromJson(String source) =>
ServerInfo.fromMap(json.decode(source));
@override
String toString() {

View File

@@ -26,7 +26,8 @@ class ServerInfoState {
mapboxInfo: mapboxInfo ?? this.mapboxInfo,
serverVersion: serverVersion ?? this.serverVersion,
isVersionMismatch: isVersionMismatch ?? this.isVersionMismatch,
versionMismatchErrorMessage: versionMismatchErrorMessage ?? this.versionMismatchErrorMessage,
versionMismatchErrorMessage:
versionMismatchErrorMessage ?? this.versionMismatchErrorMessage,
);
}
@@ -50,7 +51,8 @@ class ServerInfoState {
String toJson() => json.encode(toMap());
factory ServerInfoState.fromJson(String source) => ServerInfoState.fromMap(json.decode(source));
factory ServerInfoState.fromJson(String source) =>
ServerInfoState.fromMap(json.decode(source));
@override
String toString() {

View File

@@ -47,7 +47,8 @@ class ServerVersion {
String toJson() => json.encode(toMap());
factory ServerVersion.fromJson(String source) => ServerVersion.fromMap(json.decode(source));
factory ServerVersion.fromJson(String source) =>
ServerVersion.fromMap(json.decode(source));
@override
String toString() {

View File

@@ -36,16 +36,20 @@ class UploadProfileImageResponse {
String toJson() => json.encode(toMap());
factory UploadProfileImageResponse.fromJson(String source) => UploadProfileImageResponse.fromMap(json.decode(source));
factory UploadProfileImageResponse.fromJson(String source) =>
UploadProfileImageResponse.fromMap(json.decode(source));
@override
String toString() => 'UploadProfileImageReponse(userId: $userId, profileImagePath: $profileImagePath)';
String toString() =>
'UploadProfileImageReponse(userId: $userId, profileImagePath: $profileImagePath)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is UploadProfileImageResponse && other.userId == userId && other.profileImagePath == profileImagePath;
return other is UploadProfileImageResponse &&
other.userId == userId &&
other.profileImagePath == profileImagePath;
}
@override

View File

@@ -56,18 +56,19 @@ class User {
factory User.fromJson(String source) => User.fromMap(json.decode(source));
@override
String toString() => 'UserInfo(id: $id, email: $email, createdAt: $createdAt)';
String toString() =>
'UserInfo(id: $id, email: $email, createdAt: $createdAt)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is User &&
other.id == id &&
other.email == email &&
other.createdAt == createdAt &&
other.firstName == firstName &&
other.lastName == lastName;
other.id == id &&
other.email == email &&
other.createdAt == createdAt &&
other.firstName == firstName &&
other.lastName == lastName;
}
@override

View File

@@ -45,7 +45,7 @@ class AssetNotifier extends StateNotifier<List<ImmichAsset>> {
}
}
}
try {
await PhotoManager.editor.deleteWithIds(deleteIdList);
} catch (e) {

View File

@@ -29,13 +29,16 @@ class WebscoketState {
}
@override
String toString() => 'WebscoketState(socket: $socket, isConnected: $isConnected)';
String toString() =>
'WebscoketState(socket: $socket, isConnected: $isConnected)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is WebscoketState && other.socket == socket && other.isConnected == isConnected;
return other is WebscoketState &&
other.socket == socket &&
other.isConnected == isConnected;
}
@override
@@ -43,7 +46,8 @@ class WebscoketState {
}
class WebsocketNotifier extends StateNotifier<WebscoketState> {
WebsocketNotifier(this.ref) : super(WebscoketState(socket: null, isConnected: false)) {
WebsocketNotifier(this.ref)
: super(WebscoketState(socket: null, isConnected: false)) {
debugPrint("Init websocket instance");
}
@@ -122,6 +126,7 @@ class WebsocketNotifier extends StateNotifier<WebscoketState> {
}
}
final websocketProvider = StateNotifierProvider<WebsocketNotifier, WebscoketState>((ref) {
final websocketProvider =
StateNotifierProvider<WebsocketNotifier, WebscoketState>((ref) {
return WebsocketNotifier(ref);
});

View File

@@ -2,7 +2,8 @@ import 'dart:math';
import 'package:flutter/material.dart';
class ImmichSliverPersistentAppBarDelegate extends SliverPersistentHeaderDelegate {
class ImmichSliverPersistentAppBarDelegate
extends SliverPersistentHeaderDelegate {
final double minHeight;
final double maxHeight;
final Widget child;
@@ -20,12 +21,15 @@ class ImmichSliverPersistentAppBarDelegate extends SliverPersistentHeaderDelegat
double get maxExtent => max(maxHeight, minHeight);
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return SizedBox.expand(child: child);
}
@override
bool shouldRebuild(ImmichSliverPersistentAppBarDelegate oldDelegate) {
return maxHeight != oldDelegate.maxHeight || minHeight != oldDelegate.minHeight || child != oldDelegate.child;
return maxHeight != oldDelegate.maxHeight ||
minHeight != oldDelegate.minHeight ||
child != oldDelegate.child;
}
}

View File

@@ -15,12 +15,14 @@ class SplashScreenPage extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
HiveSavedLoginInfo? loginInfo = Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).get(savedLoginInfoKey);
HiveSavedLoginInfo? loginInfo =
Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).get(savedLoginInfoKey);
void performLoggingIn() async {
var isAuthenticated = await ref
.read(authenticationProvider.notifier)
.login(loginInfo!.email, loginInfo.password, loginInfo.serverUrl, true);
.login(
loginInfo!.email, loginInfo.password, loginInfo.serverUrl, true);
if (isAuthenticated) {
// Resume backup (if enable) then navigate

View File

@@ -9,7 +9,8 @@ class TabControllerPage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
var isMultiSelectEnable = ref.watch(homePageStateProvider).isMultiSelectEnable;
var isMultiSelectEnable =
ref.watch(homePageStateProvider).isMultiSelectEnable;
return AutoTabsRouter(
routes: [
@@ -32,16 +33,21 @@ class TabControllerPage extends ConsumerWidget {
bottomNavigationBar: isMultiSelectEnable
? null
: BottomNavigationBar(
selectedLabelStyle: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600),
unselectedLabelStyle: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600),
selectedLabelStyle: const TextStyle(
fontSize: 15, fontWeight: FontWeight.w600),
unselectedLabelStyle: const TextStyle(
fontSize: 15, fontWeight: FontWeight.w600),
currentIndex: tabsRouter.activeIndex,
onTap: (index) {
tabsRouter.setActiveIndex(index);
},
items: const [
BottomNavigationBarItem(label: 'Photos', icon: Icon(Icons.photo)),
BottomNavigationBarItem(label: 'Search', icon: Icon(Icons.search)),
BottomNavigationBarItem(label: 'Sharing', icon: Icon(Icons.group_outlined)),
BottomNavigationBarItem(
label: 'Photos', icon: Icon(Icons.photo)),
BottomNavigationBarItem(
label: 'Search', icon: Icon(Icons.search)),
BottomNavigationBarItem(
label: 'Sharing', icon: Icon(Icons.group_outlined)),
],
),
),