Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

refractor: used better code format

Aman Raj Singh Mouryaefed42ce4a7c
diff --git a/mobile/lib/ui/sharing/add_participant_page.dart b/mobile/lib/ui/sharing/add_participant_page.dart
index e5f23daa43..92c6e84e9c 100644
--- a/mobile/lib/ui/sharing/add_participant_page.dart
+++ b/mobile/lib/ui/sharing/add_participant_page.dart
@@ -20,22 +20,16 @@ import 'package:photos/ui/sharing/user_avator_widget.dart';
import "package:photos/ui/sharing/verify_identity_dialog.dart";
class AddParticipantPage extends StatefulWidget {
- final Collection? collection;
final bool isAddingViewer;
- final List<Collection>? collections;
+ final List<Collection> collections;
const AddParticipantPage(
- this.collection,
+ this.collections,
this.isAddingViewer, {
super.key,
- this.collections,
- }) : assert(
- collection != null || (collections != null),
- 'Either collection or non-empty collections must be provided',
- );
+ });
- bool get isMultipleCollections =>
- collections != null && collections!.isNotEmpty;
+ bool get isToMultipleCollections => collections.length > 1;
@override
State<StatefulWidget> createState() => _AddParticipantPage();
@@ -84,7 +78,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
resizeToAvoidBottomInset: isKeypadOpen,
appBar: AppBar(
title: Text(
- widget.isMultipleCollections
+ widget.isToMultipleCollections
? S.of(context).addParticipants
: widget.isAddingViewer
? S.of(context).addViewer
@@ -230,7 +224,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 8),
- widget.isMultipleCollections
+ widget.isToMultipleCollections
? _multipleActionButton()
: _singleActionButton(),
const SizedBox(height: 12),
@@ -253,7 +247,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
isDisabled: _selectedEmails.isEmpty,
onTap: () async {
final results = <bool>[];
- final collections = getAllCollections();
+ final collections = widget.collections;
for (String email in _selectedEmails) {
for (Collection collection in collections) {
@@ -297,7 +291,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
isDisabled: _selectedEmails.isEmpty,
onTap: () async {
final results = <bool>[];
- final collections = getAllCollections();
+ final collections = widget.collections;
for (String email in _selectedEmails) {
bool result = false;
@@ -331,7 +325,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
isDisabled: _selectedEmails.isEmpty,
onTap: () async {
final results = <bool>[];
- final collections = getAllCollections();
+ final collections = widget.collections;
for (String email in _selectedEmails) {
bool result = false;
@@ -454,18 +448,12 @@ class _AddParticipantPage extends State<AddParticipantPage> {
);
}
- List<Collection> getAllCollections() {
- if (widget.collections != null && widget.collections!.isNotEmpty) {
- return widget.collections!;
- } else if (widget.collection != null) {
- return [widget.collection!];
- }
- return [];
- }
-
List<User> _getSuggestedUser() {
final Set<String> existingEmails = {};
- final collections = getAllCollections();
+ final collections = widget.collections;
+ if (collections.isEmpty) {
+ return [];
+ }
for (final Collection collection in collections) {
for (final User u in collection.sharees) {
diff --git a/mobile/lib/ui/sharing/album_participants_page.dart b/mobile/lib/ui/sharing/album_participants_page.dart
index e27fe92478..e51f436844 100644
--- a/mobile/lib/ui/sharing/album_participants_page.dart
+++ b/mobile/lib/ui/sharing/album_participants_page.dart
@@ -54,7 +54,7 @@ class _AlbumParticipantsPageState extends State<AlbumParticipantsPage> {
Future<void> _navigateToAddUser(bool addingViewer) async {
await routeToPage(
context,
- AddParticipantPage(widget.collection, addingViewer),
+ AddParticipantPage(widget.collection as List<Collection>, addingViewer),
);
if (mounted) {
setState(() => {});
diff --git a/mobile/lib/ui/sharing/share_collection_page.dart b/mobile/lib/ui/sharing/share_collection_page.dart
index 64090528c8..d110e156b5 100644
--- a/mobile/lib/ui/sharing/share_collection_page.dart
+++ b/mobile/lib/ui/sharing/share_collection_page.dart
@@ -92,7 +92,7 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
// ignore: unawaited_futures
routeToPage(
context,
- AddParticipantPage(widget.collection, true),
+ AddParticipantPage([widget.collection], true),
).then(
(value) => {
if (mounted) {setState(() => {})},
@@ -118,8 +118,10 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
isTopBorderRadiusRemoved: true,
onTap: () async {
// ignore: unawaited_futures
- routeToPage(context, AddParticipantPage(widget.collection, false))
- .then(
+ routeToPage(
+ context,
+ AddParticipantPage([widget.collection], false),
+ ).then(
(value) => {
if (mounted) {setState(() => {})},
},
diff --git a/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart b/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart
index 93b16c67a1..9ac2dc6737 100644
--- a/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart
+++ b/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart
@@ -161,9 +161,8 @@ class _AlbumSelectionActionWidgetState
await routeToPage(
context,
AddParticipantPage(
- widget.selectedAlbums.albums.toList().first,
+ widget.selectedAlbums.albums.toList(),
false,
- collections: widget.selectedAlbums.albums.toList(),
),
);
widget.selectedAlbums.clearAll();