[mob][photos] Fix sort order setting not reflecting on public link opened in-app

This commit is contained in:
ashilkn
2024-12-24 18:13:28 +05:30
parent bd0e8e6fe6
commit 21f0602161
3 changed files with 33 additions and 5 deletions

View File

@@ -1067,6 +1067,24 @@ class CollectionsService {
_cachedPublicAlbumToken[collection.id] = authToken!;
_cachedPublicCollectionID.add(collection.id);
_cachedPublicAlbumKey[collection.id] = albumKey;
if (collectionData['pubMagicMetadata'] != null) {
final utfEncodedMmd = await CryptoUtil.decryptChaCha(
CryptoUtil.base642bin(collectionData['pubMagicMetadata']['data']),
collectionKey,
CryptoUtil.base642bin(
collectionData['pubMagicMetadata']['header'],
),
);
collection.mMdPubEncodedJson = utf8.decode(utfEncodedMmd);
collection.mMbPubVersion =
collectionData['pubMagicMetadata']['version'];
collection.pubMagicMetadata =
CollectionPubMagicMetadata.fromEncodedJson(
collection.mMdPubEncodedJson ?? '{}',
);
}
collection.setName(_getDecryptedCollectionName(collection));
return collection;
} catch (e, s) {

View File

@@ -306,8 +306,12 @@ class _HomeWidgetState extends State<HomeWidget> {
if (result) {
await dialog.show();
final List<EnteFile> sharedFiles = await _diffFetcher
.getPublicFiles(context, collection.id);
final List<EnteFile> sharedFiles =
await _diffFetcher.getPublicFiles(
context,
collection.id,
collection.pubMagicMetadata.asc ?? false,
);
await dialog.hide();
Navigator.of(context).pop();
@@ -334,8 +338,11 @@ class _HomeWidgetState extends State<HomeWidget> {
} else {
await dialog.show();
final List<EnteFile> sharedFiles =
await _diffFetcher.getPublicFiles(context, collection.id);
final List<EnteFile> sharedFiles = await _diffFetcher.getPublicFiles(
context,
collection.id,
collection.pubMagicMetadata.asc ?? false,
);
await dialog.hide();
await routeToPage(

View File

@@ -21,6 +21,7 @@ class DiffFetcher {
Future<List<EnteFile>> getPublicFiles(
BuildContext context,
int collectionID,
bool sortAsc,
) async {
try {
final authToken = await CollectionsService.instance
@@ -95,7 +96,9 @@ class DiffFetcher {
sinceTime = diff.last["updationTime"];
}
} while (hasMore);
if (sortAsc) {
sharedFiles.sort((a, b) => a.creationTime!.compareTo(b.creationTime!));
}
return sharedFiles;
} catch (e, s) {
_logger.severe("Failed to decrypt collection ", e, s);