mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 01:06:21 +01:00
Regression: dynamic album cover not shown even after opening it
This commit is contained in:
parent
0eb13273a1
commit
203eaf290a
6 changed files with 58 additions and 0 deletions
|
@ -21,6 +21,7 @@ import 'package:nc_photos/rx_extension.dart';
|
||||||
import 'package:nc_photos/use_case/collection/add_file_to_collection.dart';
|
import 'package:nc_photos/use_case/collection/add_file_to_collection.dart';
|
||||||
import 'package:nc_photos/use_case/collection/list_collection_item.dart';
|
import 'package:nc_photos/use_case/collection/list_collection_item.dart';
|
||||||
import 'package:nc_photos/use_case/collection/remove_from_collection.dart';
|
import 'package:nc_photos/use_case/collection/remove_from_collection.dart';
|
||||||
|
import 'package:nc_photos/use_case/collection/update_collection_post_load.dart';
|
||||||
import 'package:nc_photos/use_case/remove.dart';
|
import 'package:nc_photos/use_case/remove.dart';
|
||||||
import 'package:np_codegen/np_codegen.dart';
|
import 'package:np_codegen/np_codegen.dart';
|
||||||
import 'package:rxdart/rxdart.dart';
|
import 'package:rxdart/rxdart.dart';
|
||||||
|
@ -289,6 +290,11 @@ class CollectionItemsController {
|
||||||
items: items,
|
items: items,
|
||||||
hasNext: false,
|
hasNext: false,
|
||||||
));
|
));
|
||||||
|
final newCollection =
|
||||||
|
await UpdateCollectionPostLoad(_c)(account, collection, items);
|
||||||
|
if (newCollection != null) {
|
||||||
|
onCollectionUpdated(newCollection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
_dataStreamController
|
_dataStreamController
|
||||||
|
|
|
@ -79,6 +79,10 @@ abstract class CollectionAdapter {
|
||||||
|
|
||||||
/// Return if the cover of this collection has been manually set
|
/// Return if the cover of this collection has been manually set
|
||||||
bool isManualCover();
|
bool isManualCover();
|
||||||
|
|
||||||
|
/// Called when the collection items belonging to this collection is first
|
||||||
|
/// loaded
|
||||||
|
Future<Collection?> updatePostLoad(List<CollectionItem> items);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class CollectionItemAdapter {
|
abstract class CollectionItemAdapter {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import 'package:nc_photos/use_case/album/edit_album.dart';
|
||||||
import 'package:nc_photos/use_case/album/remove_album.dart';
|
import 'package:nc_photos/use_case/album/remove_album.dart';
|
||||||
import 'package:nc_photos/use_case/album/remove_from_album.dart';
|
import 'package:nc_photos/use_case/album/remove_from_album.dart';
|
||||||
import 'package:nc_photos/use_case/preprocess_album.dart';
|
import 'package:nc_photos/use_case/preprocess_album.dart';
|
||||||
|
import 'package:nc_photos/use_case/update_album_with_actual_items.dart';
|
||||||
import 'package:np_codegen/np_codegen.dart';
|
import 'package:np_codegen/np_codegen.dart';
|
||||||
import 'package:np_common/type.dart';
|
import 'package:np_common/type.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
@ -222,6 +223,23 @@ class CollectionAlbumAdapter implements CollectionAdapter {
|
||||||
bool isManualCover() =>
|
bool isManualCover() =>
|
||||||
_provider.album.coverProvider is AlbumManualCoverProvider;
|
_provider.album.coverProvider is AlbumManualCoverProvider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Collection?> updatePostLoad(List<CollectionItem> items) async {
|
||||||
|
final album = await UpdateAlbumWithActualItems(_c.albumRepo)(
|
||||||
|
account,
|
||||||
|
_provider.album,
|
||||||
|
items
|
||||||
|
.whereType<AlbumAdaptedCollectionItem>()
|
||||||
|
.map((e) => e.albumItem)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
if (!identical(album, _provider.album)) {
|
||||||
|
return CollectionBuilder.byAlbum(account, album);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final DiContainer _c;
|
final DiContainer _c;
|
||||||
final Account account;
|
final Account account;
|
||||||
final Collection collection;
|
final Collection collection;
|
||||||
|
|
|
@ -145,6 +145,10 @@ class CollectionNcAlbumAdapter implements CollectionAdapter {
|
||||||
@override
|
@override
|
||||||
bool isManualCover() => false;
|
bool isManualCover() => false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Collection?> updatePostLoad(List<CollectionItem> items) =>
|
||||||
|
Future.value(null);
|
||||||
|
|
||||||
Future<NcAlbum> _syncRemote() async {
|
Future<NcAlbum> _syncRemote() async {
|
||||||
final remote = await ListNcAlbum(_c)(account).last;
|
final remote = await ListNcAlbum(_c)(account).last;
|
||||||
return remote.firstWhere((e) => e.compareIdentity(_provider.album));
|
return remote.firstWhere((e) => e.compareIdentity(_provider.album));
|
||||||
|
|
|
@ -42,4 +42,8 @@ mixin CollectionReadOnlyAdapter implements CollectionAdapter {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isManualCover() => false;
|
bool isManualCover() => false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Collection?> updatePostLoad(List<CollectionItem> items) =>
|
||||||
|
Future.value(null);
|
||||||
}
|
}
|
||||||
|
|
22
app/lib/use_case/collection/update_collection_post_load.dart
Normal file
22
app/lib/use_case/collection/update_collection_post_load.dart
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import 'package:nc_photos/account.dart';
|
||||||
|
import 'package:nc_photos/di_container.dart';
|
||||||
|
import 'package:nc_photos/entity/collection.dart';
|
||||||
|
import 'package:nc_photos/entity/collection/adapter.dart';
|
||||||
|
import 'package:nc_photos/entity/collection_item.dart';
|
||||||
|
|
||||||
|
class UpdateCollectionPostLoad {
|
||||||
|
const UpdateCollectionPostLoad(this._c);
|
||||||
|
|
||||||
|
/// Update the collection after its items are loaded if necessary
|
||||||
|
///
|
||||||
|
/// Return a new collection if its updated, otherwise null
|
||||||
|
Future<Collection?> call(
|
||||||
|
Account account,
|
||||||
|
Collection collection,
|
||||||
|
List<CollectionItem> items,
|
||||||
|
) {
|
||||||
|
return CollectionAdapter.of(_c, account, collection).updatePostLoad(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
final DiContainer _c;
|
||||||
|
}
|
Loading…
Reference in a new issue