mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Fix shared collection not shown in HomeCollections after importing
This commit is contained in:
parent
24d878b93e
commit
39f356e0a1
2 changed files with 25 additions and 4 deletions
|
@ -19,6 +19,7 @@ import 'package:nc_photos/or_null.dart';
|
|||
import 'package:nc_photos/rx_extension.dart';
|
||||
import 'package:nc_photos/use_case/collection/create_collection.dart';
|
||||
import 'package:nc_photos/use_case/collection/edit_collection.dart';
|
||||
import 'package:nc_photos/use_case/collection/import_pending_shared_collection.dart';
|
||||
import 'package:nc_photos/use_case/collection/list_collection.dart';
|
||||
import 'package:nc_photos/use_case/collection/remove_collections.dart';
|
||||
import 'package:nc_photos/use_case/collection/share_collection.dart';
|
||||
|
@ -261,6 +262,25 @@ class CollectionsController {
|
|||
}
|
||||
}
|
||||
|
||||
/// See [ImportPendingSharedCollection]
|
||||
Future<Collection?> importPendingSharedCollection(
|
||||
Collection collection) async {
|
||||
try {
|
||||
final newCollection =
|
||||
await ImportPendingSharedCollection(_c)(account, collection);
|
||||
_dataStreamController.addWithValue((v) => v.copyWith(
|
||||
data: _prepareDataFor([
|
||||
newCollection,
|
||||
...v.data.map((e) => e.collection),
|
||||
]),
|
||||
));
|
||||
return newCollection;
|
||||
} catch (e, stackTrace) {
|
||||
_dataStreamController.addError(e, stackTrace);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
var lastData = const CollectionStreamEvent(
|
||||
data: [],
|
||||
|
|
|
@ -140,10 +140,11 @@ class _Bloc extends Bloc<_Event, _State> implements BlocTag {
|
|||
Future<void> _onImportPendingSharedCollection(
|
||||
_ImportPendingSharedCollection ev, Emitter<_State> emit) async {
|
||||
_log.info(ev);
|
||||
// pending collections are always ad hoc
|
||||
final newCollection =
|
||||
await ImportPendingSharedCollection(_c)(account, state.collection);
|
||||
emit(state.copyWith(importResult: newCollection));
|
||||
final newCollection = await collectionsController
|
||||
.importPendingSharedCollection(state.collection);
|
||||
if (newCollection != null) {
|
||||
emit(state.copyWith(importResult: newCollection));
|
||||
}
|
||||
}
|
||||
|
||||
void _onBeginEdit(_BeginEdit ev, Emitter<_State> emit) {
|
||||
|
|
Loading…
Reference in a new issue