Skip to content

Conversation

@alextran1502
Copy link
Member

@alextran1502 alextran1502 commented Aug 20, 2025

Close #20341

@alextran1502 alextran1502 force-pushed the album-info-sync branch 3 times, most recently from 8611858 to 69c24fe Compare August 23, 2025 20:36

final syncLinkedAlbumProvider = NotifierProvider<SyncLinkedAlbumNotifier, bool>(SyncLinkedAlbumNotifier.new);

class SyncLinkedAlbumNotifier extends Notifier<bool> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be a service and a simple provider can be used to locate the service

return _db.managers.localAssetEntity.filter((e) => e.checksum.isNull().not()).count();
}

Future<List<LocalAlbum>> getAlbumsForAsset(String assetId) async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused method

Comment on lines 41 to 55
syncAlbums() async {
setState(() {
isAlbumSyncInProgress = true;
});
try {
ref.read(syncLinkedAlbumProvider.notifier).syncLinkedAlbums();
} catch (_) {
} finally {
Future.delayed(const Duration(seconds: 1), () {
setState(() {
isAlbumSyncInProgress = false;
});
});
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not throw the loading state inside a provider and handle it properly than just showing the indicator for 1 second always? Also, it feels weird that we have to enable the "Sync Albums" option inside the album selection page to have the sync albums show up in the settings page.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for manually running the sync process, especially for cases where you later decide to use the sync feature. In the album selection, the linked album aren't created until you are navigate away from the page, meaning the selected albums are finalized

Copy link
Member

@shenlong-tanwen shenlong-tanwen Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could instead do the following:

  • Either have a section in the backup settings for sync albums and allow the user to enable or disable it there, along with a button to manually run it on demand
  • Always show the manual sync button but keep it disabled until the sync albums setting is enabled (This can be coupled with the above suggestion)

In both cases, wouldn't it also be better if we showed the actual progress and prevent the user from tapping the button multiple times instead of a 1s indicator

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds pretty good

return _db.managers.remoteAlbumEntity.count();
}

Future<List<String>> getLinkedAssetIds(String userId, String localAlbumId, String remoteAlbumId) async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called the other way? i.e, getUnLinkedIds as we are returning the assets to be linked and not those that are already linked?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically, it is for "getting linked album assets that has not been added" lol. Told you the hardest part of the PR is naming :P

@alextran1502 alextran1502 marked this pull request as ready for review September 4, 2025 18:29
Comment on lines 207 to 228
Future<void> syncLinkedAlbums(String userId, List<LocalAlbum> selectedAlbums) async {
await Future.wait(
selectedAlbums.map((localAlbum) async {
final linkedRemoteAlbumId = localAlbum.linkedRemoteAlbumId;
if (linkedRemoteAlbumId == null) {
return;
}

final remoteAlbum = await get(linkedRemoteAlbumId);
if (remoteAlbum == null) {
return;
}

// get assets that are uploaded but not in the remote album
final assetIds = await _repository.getLinkedAssetIds(userId, localAlbum.id, linkedRemoteAlbumId);

if (assetIds.isNotEmpty) {
await addAssets(albumId: linkedRemoteAlbumId, assetIds: assetIds);
}
}),
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost similar to the syncLinkedAlbums method on SyncLinkedAlbumService

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this is an unsued method

@alextran1502 alextran1502 enabled auto-merge (squash) September 4, 2025 18:39
@alextran1502 alextran1502 merged commit bcfb5be into main Sep 4, 2025
53 checks passed
@alextran1502 alextran1502 deleted the album-info-sync branch September 4, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[beta] album sync feature not working

3 participants