Fix: create uncat collection if not already created

This commit is contained in:
Neeraj Gupta 2023-01-17 13:50:17 +05:30
parent 84e40d6d31
commit ddb27cf438
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/models/collection.dart';
import 'package:photos/services/collections_service.dart';
import 'package:photos/services/hidden_service.dart';
import 'package:photos/ui/viewer/gallery/uncategorized_page.dart';
import 'package:photos/utils/navigation_util.dart';
@ -19,6 +20,10 @@ class UnCatCollectionsButtonWidget extends StatelessWidget {
final Collection? collection = CollectionsService.instance
.getActiveCollections()
.firstWhereOrNull((e) => e.type == CollectionType.uncategorized);
if (collection == null) {
// create uncategorized collection if it's not already created
CollectionsService.instance.getUncategorizedCollection().ignore();
}
return OutlinedButton(
style: OutlinedButton.styleFrom(
backgroundColor: Theme.of(context).backgroundColor,