mirror of
https://github.com/immich-app/immich.git
synced 2025-05-30 19:54:52 -04:00
add full sync button
This commit is contained in:
parent
7e5f88e678
commit
a41a156ce4
@ -137,6 +137,6 @@ open class NativeSyncApiImplBase(context: Context) {
|
|||||||
return albums.map { album ->
|
return albums.map { album ->
|
||||||
val count = albumsCount[album.id] ?: 0
|
val count = albumsCount[album.id] ?: 0
|
||||||
album.copy(assetCount = count.toLong())
|
album.copy(assetCount = count.toLong())
|
||||||
}
|
}.sortedBy { it.id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ class DeviceSyncService {
|
|||||||
bool get _ignoreIcloudAssets =>
|
bool get _ignoreIcloudAssets =>
|
||||||
_storeService.get(StoreKey.ignoreIcloudAssets, false) == true;
|
_storeService.get(StoreKey.ignoreIcloudAssets, false) == true;
|
||||||
|
|
||||||
Future<void> sync() async {
|
Future<void> sync({bool full = false}) async {
|
||||||
final Stopwatch stopwatch = Stopwatch()..start();
|
final Stopwatch stopwatch = Stopwatch()..start();
|
||||||
try {
|
try {
|
||||||
if (await _nativeSyncApi.shouldFullSync()) {
|
if (full || await _nativeSyncApi.shouldFullSync()) {
|
||||||
_log.fine("Cannot use partial sync. Performing full sync");
|
_log.fine("Full sync request from ${full ? "user" : "native"}");
|
||||||
DLog.log("Cannot use partial sync. Performing full sync");
|
DLog.log("Full sync request from ${full ? "user" : "native"}");
|
||||||
return await fullSync();
|
return await fullSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,13 +23,14 @@ class BackgroundSyncManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No need to cancel the task, as it can also be run when the user logs out
|
// No need to cancel the task, as it can also be run when the user logs out
|
||||||
Future<void> syncLocal() {
|
Future<void> syncLocal({bool full = false}) {
|
||||||
if (_deviceAlbumSyncTask != null) {
|
if (_deviceAlbumSyncTask != null) {
|
||||||
return _deviceAlbumSyncTask!.future;
|
return _deviceAlbumSyncTask!.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
_deviceAlbumSyncTask = runInIsolateGentle(
|
_deviceAlbumSyncTask = runInIsolateGentle(
|
||||||
computation: (ref) => ref.read(deviceSyncServiceProvider).sync(),
|
computation: (ref) =>
|
||||||
|
ref.read(deviceSyncServiceProvider).sync(full: full),
|
||||||
);
|
);
|
||||||
|
|
||||||
return _deviceAlbumSyncTask!.whenComplete(() {
|
return _deviceAlbumSyncTask!.whenComplete(() {
|
||||||
|
@ -21,6 +21,11 @@ final _features = [
|
|||||||
icon: Icons.photo_album_rounded,
|
icon: Icons.photo_album_rounded,
|
||||||
onTap: (_, ref) => ref.read(backgroundSyncProvider).syncLocal(),
|
onTap: (_, ref) => ref.read(backgroundSyncProvider).syncLocal(),
|
||||||
),
|
),
|
||||||
|
_Feature(
|
||||||
|
name: 'Sync Local Full',
|
||||||
|
icon: Icons.photo_library_rounded,
|
||||||
|
onTap: (_, ref) => ref.read(backgroundSyncProvider).syncLocal(full: true),
|
||||||
|
),
|
||||||
_Feature(
|
_Feature(
|
||||||
name: 'Sync Remote',
|
name: 'Sync Remote',
|
||||||
icon: Icons.refresh_rounded,
|
icon: Icons.refresh_rounded,
|
||||||
@ -69,6 +74,7 @@ class FeatInDevPage extends StatelessWidget {
|
|||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
final feat = _features[index];
|
final feat = _features[index];
|
||||||
@ -76,6 +82,7 @@ class FeatInDevPage extends StatelessWidget {
|
|||||||
builder: (ctx, ref, _) => ListTile(
|
builder: (ctx, ref, _) => ListTile(
|
||||||
title: Text(feat.name),
|
title: Text(feat.name),
|
||||||
trailing: Icon(feat.icon),
|
trailing: Icon(feat.icon),
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
onTap: () => unawaited(feat.onTap(ctx, ref)),
|
onTap: () => unawaited(feat.onTap(ctx, ref)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user