mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04:00
show dev route in profile mode
This commit is contained in:
parent
57668a8382
commit
28434aa6d1
@ -16,7 +16,7 @@ class DeviceSyncService {
|
|||||||
final ILocalAlbumRepository _localAlbumRepository;
|
final ILocalAlbumRepository _localAlbumRepository;
|
||||||
final Platform _platform;
|
final Platform _platform;
|
||||||
final platform.ImHostService _hostService;
|
final platform.ImHostService _hostService;
|
||||||
final Logger _log = Logger("SyncService");
|
final Logger _log = Logger("DeviceSyncService");
|
||||||
|
|
||||||
DeviceSyncService({
|
DeviceSyncService({
|
||||||
required IAlbumMediaRepository albumMediaRepository,
|
required IAlbumMediaRepository albumMediaRepository,
|
||||||
@ -29,6 +29,7 @@ class DeviceSyncService {
|
|||||||
_hostService = hostService;
|
_hostService = hostService;
|
||||||
|
|
||||||
Future<void> sync() async {
|
Future<void> sync() async {
|
||||||
|
final Stopwatch stopwatch = Stopwatch()..start();
|
||||||
try {
|
try {
|
||||||
if (await _hostService.shouldFullSync()) {
|
if (await _hostService.shouldFullSync()) {
|
||||||
_log.fine("Cannot use partial sync. Performing full sync");
|
_log.fine("Cannot use partial sync. Performing full sync");
|
||||||
@ -57,6 +58,8 @@ class DeviceSyncService {
|
|||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
_log.severe("Error performing device sync", e, s);
|
_log.severe("Error performing device sync", e, s);
|
||||||
}
|
}
|
||||||
|
stopwatch.stop();
|
||||||
|
_log.info("Device sync took - ${stopwatch.elapsedMilliseconds}ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> fullSync() async {
|
Future<void> fullSync() async {
|
||||||
@ -91,7 +94,7 @@ class DeviceSyncService {
|
|||||||
|
|
||||||
Future<void> addAlbum(LocalAlbum newAlbum) async {
|
Future<void> addAlbum(LocalAlbum newAlbum) async {
|
||||||
try {
|
try {
|
||||||
_log.info("Adding device album ${newAlbum.name}");
|
_log.fine("Adding device album ${newAlbum.name}");
|
||||||
final album = await _albumMediaRepository.refresh(newAlbum.id);
|
final album = await _albumMediaRepository.refresh(newAlbum.id);
|
||||||
|
|
||||||
final assets = album.assetCount > 0
|
final assets = album.assetCount > 0
|
||||||
@ -106,7 +109,7 @@ class DeviceSyncService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> removeAlbum(LocalAlbum a) async {
|
Future<void> removeAlbum(LocalAlbum a) async {
|
||||||
_log.info("Removing device album ${a.name}");
|
_log.fine("Removing device album ${a.name}");
|
||||||
try {
|
try {
|
||||||
// Asset deletion is handled in the repository
|
// Asset deletion is handled in the repository
|
||||||
await _localAlbumRepository.delete(a.id);
|
await _localAlbumRepository.delete(a.id);
|
||||||
@ -118,7 +121,7 @@ class DeviceSyncService {
|
|||||||
// The deviceAlbum is ignored since we are going to refresh it anyways
|
// The deviceAlbum is ignored since we are going to refresh it anyways
|
||||||
FutureOr<bool> updateAlbum(LocalAlbum dbAlbum, LocalAlbum _) async {
|
FutureOr<bool> updateAlbum(LocalAlbum dbAlbum, LocalAlbum _) async {
|
||||||
try {
|
try {
|
||||||
_log.info("Syncing device album ${dbAlbum.name}");
|
_log.fine("Syncing device album ${dbAlbum.name}");
|
||||||
|
|
||||||
final deviceAlbum = await _albumMediaRepository.refresh(dbAlbum.id);
|
final deviceAlbum = await _albumMediaRepository.refresh(dbAlbum.id);
|
||||||
|
|
||||||
@ -131,7 +134,7 @@ class DeviceSyncService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.info("Device album ${dbAlbum.name} has changed. Syncing...");
|
_log.fine("Device album ${dbAlbum.name} has changed. Syncing...");
|
||||||
|
|
||||||
// Faster path - only new assets added
|
// Faster path - only new assets added
|
||||||
if (await checkAddition(dbAlbum, deviceAlbum)) {
|
if (await checkAddition(dbAlbum, deviceAlbum)) {
|
||||||
|
71
mobile/lib/platform/messages.g.dart
generated
71
mobile/lib/platform/messages.g.dart
generated
@ -14,21 +14,22 @@ PlatformException _createConnectionError(String channelName) {
|
|||||||
message: 'Unable to establish connection on channel: "$channelName".',
|
message: 'Unable to establish connection on channel: "$channelName".',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _deepEquals(Object? a, Object? b) {
|
bool _deepEquals(Object? a, Object? b) {
|
||||||
if (a is List && b is List) {
|
if (a is List && b is List) {
|
||||||
return a.length == b.length &&
|
return a.length == b.length &&
|
||||||
a.indexed
|
a.indexed
|
||||||
.every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]));
|
.every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]));
|
||||||
}
|
}
|
||||||
if (a is Map && b is Map) {
|
if (a is Map && b is Map) {
|
||||||
return a.length == b.length && a.entries.every((MapEntry<Object?, Object?> entry) =>
|
return a.length == b.length &&
|
||||||
(b as Map<Object?, Object?>).containsKey(entry.key) &&
|
a.entries.every((MapEntry<Object?, Object?> entry) =>
|
||||||
_deepEquals(entry.value, b[entry.key]));
|
(b as Map<Object?, Object?>).containsKey(entry.key) &&
|
||||||
|
_deepEquals(entry.value, b[entry.key]));
|
||||||
}
|
}
|
||||||
return a == b;
|
return a == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class PlatformAsset {
|
class PlatformAsset {
|
||||||
PlatformAsset({
|
PlatformAsset({
|
||||||
required this.id,
|
required this.id,
|
||||||
@ -67,7 +68,8 @@ class PlatformAsset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object encode() {
|
Object encode() {
|
||||||
return _toList(); }
|
return _toList();
|
||||||
|
}
|
||||||
|
|
||||||
static PlatformAsset decode(Object result) {
|
static PlatformAsset decode(Object result) {
|
||||||
result as List<Object?>;
|
result as List<Object?>;
|
||||||
@ -96,8 +98,7 @@ class PlatformAsset {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||||
int get hashCode => Object.hashAll(_toList())
|
int get hashCode => Object.hashAll(_toList());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SyncDelta {
|
class SyncDelta {
|
||||||
@ -122,7 +123,8 @@ class SyncDelta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object encode() {
|
Object encode() {
|
||||||
return _toList(); }
|
return _toList();
|
||||||
|
}
|
||||||
|
|
||||||
static SyncDelta decode(Object result) {
|
static SyncDelta decode(Object result) {
|
||||||
result as List<Object?>;
|
result as List<Object?>;
|
||||||
@ -147,11 +149,9 @@ class SyncDelta {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||||
int get hashCode => Object.hashAll(_toList())
|
int get hashCode => Object.hashAll(_toList());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _PigeonCodec extends StandardMessageCodec {
|
class _PigeonCodec extends StandardMessageCodec {
|
||||||
const _PigeonCodec();
|
const _PigeonCodec();
|
||||||
@override
|
@override
|
||||||
@ -159,10 +159,10 @@ class _PigeonCodec extends StandardMessageCodec {
|
|||||||
if (value is int) {
|
if (value is int) {
|
||||||
buffer.putUint8(4);
|
buffer.putUint8(4);
|
||||||
buffer.putInt64(value);
|
buffer.putInt64(value);
|
||||||
} else if (value is PlatformAsset) {
|
} else if (value is PlatformAsset) {
|
||||||
buffer.putUint8(129);
|
buffer.putUint8(129);
|
||||||
writeValue(buffer, value.encode());
|
writeValue(buffer, value.encode());
|
||||||
} else if (value is SyncDelta) {
|
} else if (value is SyncDelta) {
|
||||||
buffer.putUint8(130);
|
buffer.putUint8(130);
|
||||||
writeValue(buffer, value.encode());
|
writeValue(buffer, value.encode());
|
||||||
} else {
|
} else {
|
||||||
@ -173,9 +173,9 @@ class _PigeonCodec extends StandardMessageCodec {
|
|||||||
@override
|
@override
|
||||||
Object? readValueOfType(int type, ReadBuffer buffer) {
|
Object? readValueOfType(int type, ReadBuffer buffer) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 129:
|
case 129:
|
||||||
return PlatformAsset.decode(readValue(buffer)!);
|
return PlatformAsset.decode(readValue(buffer)!);
|
||||||
case 130:
|
case 130:
|
||||||
return SyncDelta.decode(readValue(buffer)!);
|
return SyncDelta.decode(readValue(buffer)!);
|
||||||
default:
|
default:
|
||||||
return super.readValueOfType(type, buffer);
|
return super.readValueOfType(type, buffer);
|
||||||
@ -187,9 +187,11 @@ class ImHostService {
|
|||||||
/// Constructor for [ImHostService]. The [binaryMessenger] named argument is
|
/// Constructor for [ImHostService]. The [binaryMessenger] named argument is
|
||||||
/// available for dependency injection. If it is left null, the default
|
/// available for dependency injection. If it is left null, the default
|
||||||
/// BinaryMessenger will be used which routes to the host platform.
|
/// BinaryMessenger will be used which routes to the host platform.
|
||||||
ImHostService({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
ImHostService(
|
||||||
|
{BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
||||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
: pigeonVar_binaryMessenger = binaryMessenger,
|
||||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
pigeonVar_messageChannelSuffix =
|
||||||
|
messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
final BinaryMessenger? pigeonVar_binaryMessenger;
|
||||||
|
|
||||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||||
@ -197,8 +199,10 @@ class ImHostService {
|
|||||||
final String pigeonVar_messageChannelSuffix;
|
final String pigeonVar_messageChannelSuffix;
|
||||||
|
|
||||||
Future<bool> shouldFullSync() async {
|
Future<bool> shouldFullSync() async {
|
||||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.immich_mobile.ImHostService.shouldFullSync$pigeonVar_messageChannelSuffix';
|
final String pigeonVar_channelName =
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
'dev.flutter.pigeon.immich_mobile.ImHostService.shouldFullSync$pigeonVar_messageChannelSuffix';
|
||||||
|
final BasicMessageChannel<Object?> pigeonVar_channel =
|
||||||
|
BasicMessageChannel<Object?>(
|
||||||
pigeonVar_channelName,
|
pigeonVar_channelName,
|
||||||
pigeonChannelCodec,
|
pigeonChannelCodec,
|
||||||
binaryMessenger: pigeonVar_binaryMessenger,
|
binaryMessenger: pigeonVar_binaryMessenger,
|
||||||
@ -225,8 +229,10 @@ class ImHostService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<SyncDelta> getMediaChanges() async {
|
Future<SyncDelta> getMediaChanges() async {
|
||||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.immich_mobile.ImHostService.getMediaChanges$pigeonVar_messageChannelSuffix';
|
final String pigeonVar_channelName =
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
'dev.flutter.pigeon.immich_mobile.ImHostService.getMediaChanges$pigeonVar_messageChannelSuffix';
|
||||||
|
final BasicMessageChannel<Object?> pigeonVar_channel =
|
||||||
|
BasicMessageChannel<Object?>(
|
||||||
pigeonVar_channelName,
|
pigeonVar_channelName,
|
||||||
pigeonChannelCodec,
|
pigeonChannelCodec,
|
||||||
binaryMessenger: pigeonVar_binaryMessenger,
|
binaryMessenger: pigeonVar_binaryMessenger,
|
||||||
@ -253,8 +259,10 @@ class ImHostService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkpointSync() async {
|
Future<void> checkpointSync() async {
|
||||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.immich_mobile.ImHostService.checkpointSync$pigeonVar_messageChannelSuffix';
|
final String pigeonVar_channelName =
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
'dev.flutter.pigeon.immich_mobile.ImHostService.checkpointSync$pigeonVar_messageChannelSuffix';
|
||||||
|
final BasicMessageChannel<Object?> pigeonVar_channel =
|
||||||
|
BasicMessageChannel<Object?>(
|
||||||
pigeonVar_channelName,
|
pigeonVar_channelName,
|
||||||
pigeonChannelCodec,
|
pigeonChannelCodec,
|
||||||
binaryMessenger: pigeonVar_binaryMessenger,
|
binaryMessenger: pigeonVar_binaryMessenger,
|
||||||
@ -276,8 +284,10 @@ class ImHostService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clearSyncCheckpoint() async {
|
Future<void> clearSyncCheckpoint() async {
|
||||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.immich_mobile.ImHostService.clearSyncCheckpoint$pigeonVar_messageChannelSuffix';
|
final String pigeonVar_channelName =
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
'dev.flutter.pigeon.immich_mobile.ImHostService.clearSyncCheckpoint$pigeonVar_messageChannelSuffix';
|
||||||
|
final BasicMessageChannel<Object?> pigeonVar_channel =
|
||||||
|
BasicMessageChannel<Object?>(
|
||||||
pigeonVar_channelName,
|
pigeonVar_channelName,
|
||||||
pigeonChannelCodec,
|
pigeonChannelCodec,
|
||||||
binaryMessenger: pigeonVar_binaryMessenger,
|
binaryMessenger: pigeonVar_binaryMessenger,
|
||||||
@ -299,13 +309,16 @@ class ImHostService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<String>> getAssetIdsForAlbum(String albumId) async {
|
Future<List<String>> getAssetIdsForAlbum(String albumId) async {
|
||||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.immich_mobile.ImHostService.getAssetIdsForAlbum$pigeonVar_messageChannelSuffix';
|
final String pigeonVar_channelName =
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
'dev.flutter.pigeon.immich_mobile.ImHostService.getAssetIdsForAlbum$pigeonVar_messageChannelSuffix';
|
||||||
|
final BasicMessageChannel<Object?> pigeonVar_channel =
|
||||||
|
BasicMessageChannel<Object?>(
|
||||||
pigeonVar_channelName,
|
pigeonVar_channelName,
|
||||||
pigeonChannelCodec,
|
pigeonChannelCodec,
|
||||||
binaryMessenger: pigeonVar_binaryMessenger,
|
binaryMessenger: pigeonVar_binaryMessenger,
|
||||||
);
|
);
|
||||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[albumId]);
|
final Future<Object?> pigeonVar_sendFuture =
|
||||||
|
pigeonVar_channel.send(<Object?>[albumId]);
|
||||||
final List<Object?>? pigeonVar_replyList =
|
final List<Object?>? pigeonVar_replyList =
|
||||||
await pigeonVar_sendFuture as List<Object?>?;
|
await pigeonVar_sendFuture as List<Object?>?;
|
||||||
if (pigeonVar_replyList == null) {
|
if (pigeonVar_replyList == null) {
|
||||||
|
@ -179,7 +179,7 @@ class ImmichAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
|||||||
child: action,
|
child: action,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (kDebugMode)
|
if (kDebugMode || kProfileMode)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.science_rounded),
|
icon: const Icon(Icons.science_rounded),
|
||||||
onPressed: () => context.pushRoute(const FeatInDevRoute()),
|
onPressed: () => context.pushRoute(const FeatInDevRoute()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user