Replace collection.name usage with collection.displayName

This commit is contained in:
Neeraj Gupta 2023-05-23 10:26:48 +05:30
parent 461bce2329
commit e2e1d7ef13
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
16 changed files with 33 additions and 29 deletions

View file

@ -9,6 +9,7 @@ class Collection {
final User? owner;
final String encryptedKey;
final String? keyDecryptionNonce;
@Deprecated("Use collectionName instead")
final String? name;
// encryptedName & nameDecryptionNonce will be null for collections
// created before we started encrypting collection name
@ -38,6 +39,8 @@ class Collection {
set magicMetadata(val) => _mmd = val;
String get displayName => decryptedName ?? name ?? "Unnamed collection";
Collection(
this.id,
this.owner,
@ -97,8 +100,6 @@ class Collection {
return (owner?.id ?? 0) == userID;
}
String get collectionName => name ?? "Unnamed collection";
void updateSharees(List<User> newSharees) {
sharees?.clear();
sharees?.addAll(newSharees);

View file

@ -55,11 +55,12 @@ class DuplicateFiles {
sortByCollectionName() {
files.sort((first, second) {
final firstName =
collectionsService.getCollectionByID(first.collectionID!)!.name ?? '';
final secondName =
collectionsService.getCollectionByID(second.collectionID!)!.name ??
'';
final firstName = collectionsService
.getCollectionByID(first.collectionID!)!
.displayName;
final secondName = collectionsService
.getCollectionByID(second.collectionID!)!
.displayName;
return firstName.compareTo(secondName);
});
}

View file

@ -14,7 +14,7 @@ class AlbumSearchResult extends SearchResult {
@override
String name() {
return collectionWithThumbnail.collection.name!;
return collectionWithThumbnail.collection.displayName;
}
@override

View file

@ -76,7 +76,7 @@ class SearchService {
if (!c.collection.isHidden() &&
c.collection.type != CollectionType.uncategorized &&
c.collection.name!.toLowerCase().contains(
c.collection.displayName.toLowerCase().contains(
query.toLowerCase(),
)) {
collectionSearchResults.add(AlbumSearchResult(c));

View file

@ -81,7 +81,7 @@ class CollectionActions {
title: S.of(context).removePublicLink,
body:
//'This will remove the public link for accessing "${collection.name}".',
S.of(context).disableLinkMessage(collection.collectionName),
S.of(context).disableLinkMessage(collection.displayName),
);
if (actionResult?.action != null) {
if (actionResult!.action == ButtonAction.error) {

View file

@ -218,7 +218,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
final searchResults = _searchQuery.isNotEmpty
? collectionsWithThumbnail
.where(
(element) => element.collection.name!
(element) => element.collection.displayName
.toLowerCase()
.contains(_searchQuery),
)
@ -263,8 +263,8 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
);
collectionsWithThumbnail.sort((first, second) {
return compareAsciiLowerCaseNatural(
first.collection.name ?? "",
second.collection.name ?? "",
first.collection.displayName,
second.collection.displayName,
);
});
return collectionsWithThumbnail;

View file

@ -62,7 +62,7 @@ class CollectionItem extends StatelessWidget {
children: [
const SizedBox(height: 2),
Text(
(c.collection.collectionName).trim(),
(c.collection.displayName).trim(),
style: enteTextTheme.small,
overflow: TextOverflow.ellipsis,
),

View file

@ -107,8 +107,8 @@ class _CollectionsGalleryWidgetState extends State<CollectionsGalleryWidget>
(first, second) {
if (sortKey == AlbumSortKey.albumName) {
return compareAsciiLowerCaseNatural(
first.collection.name!,
second.collection.name!,
first.collection.displayName,
second.collection.displayName,
);
} else if (sortKey == AlbumSortKey.newestPhoto) {
return (second.thumbnail?.creationTime ?? -1 * intMaxValue)

View file

@ -181,12 +181,14 @@ class CollectionsListWidget extends StatelessWidget {
late final String toastMessage;
bool shouldNavigateToCollection = false;
if (actionType == CollectionActionType.addFiles) {
toastMessage = S.of(context).addedSuccessfullyTo(item.collection.name!);
toastMessage =
S.of(context).addedSuccessfullyTo(item.collection.displayName);
shouldNavigateToCollection = true;
} else if (actionType == CollectionActionType.moveFiles ||
actionType == CollectionActionType.restoreFiles ||
actionType == CollectionActionType.unHide) {
toastMessage = S.of(context).movedSuccessfullyTo(item.collection.name!);
toastMessage =
S.of(context).movedSuccessfullyTo(item.collection.displayName);
shouldNavigateToCollection = true;
} else {
toastMessage = "";
@ -275,7 +277,7 @@ class CollectionsListWidget extends StatelessWidget {
.updateShareUrl(collection, {'enableCollect': true}).then(
(value) => showShortToast(
context,
S.of(context).collaborativeLinkCreatedFor(collection.name!),
S.of(context).collaborativeLinkCreatedFor(collection.displayName),
),
);
return true;
@ -293,7 +295,7 @@ class CollectionsListWidget extends StatelessWidget {
if (result) {
showShortToast(
context,
S.of(context).collaborativeLinkCreatedFor(collection.name!),
S.of(context).collaborativeLinkCreatedFor(collection.displayName),
);
if (Configuration.instance.getUserID() == collection.owner!.id) {
unawaited(

View file

@ -52,7 +52,7 @@ class AlbumListItemWidget extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(item.collection.collectionName),
Text(item.collection.displayName),
FutureBuilder<int>(
future: FilesDB.instance.collectionFileCount(
item.collection.id,

View file

@ -343,7 +343,7 @@ class OutgoingCollectionItem extends StatelessWidget {
Row(
children: [
Text(
c.collection.name!,
c.collection.displayName,
style: const TextStyle(
fontSize: 16,
),
@ -449,7 +449,7 @@ class IncomingCollectionItem extends StatelessWidget {
Container(
constraints: BoxConstraints(maxWidth: sideOfThumbnail - 40),
child: Text(
c.collection.name!,
c.collection.displayName,
style: albumTitleTextStyle,
overflow: TextOverflow.ellipsis,
),

View file

@ -83,7 +83,7 @@ class _AlbumParticipantsPageState extends State<AlbumParticipantsPage> {
slivers: <Widget>[
TitleBarWidget(
flexibleSpaceTitle: TitleBarTitleWidget(
title: "${widget.collection.name}",
title: widget.collection.displayName,
),
flexibleSpaceCaption:
S.of(context).albumParticipantsCount(participants),

View file

@ -288,7 +288,7 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
return Scaffold(
appBar: AppBar(
title: Text(
widget.collection.name ?? "Unnamed",
widget.collection.displayName,
style: Theme.of(context).textTheme.headline5?.copyWith(fontSize: 16),
),
elevation: 0,

View file

@ -480,7 +480,7 @@ class _DeduplicatePageState extends State<DeduplicatePage> {
child: Text(
CollectionsService.instance
.getCollectionByID(file.collectionID!)!
.name!,
.displayName,
style:
Theme.of(context).textTheme.caption!.copyWith(fontSize: 12),
overflow: TextOverflow.ellipsis,

View file

@ -83,7 +83,7 @@ class AlbumsItemWidget extends StatelessWidget {
collections.add(c!);
chipButtons.add(
ChipButtonWidget(
c.isHidden() ? S.of(context).hidden : c.name,
c.isHidden() ? S.of(context).hidden : c.displayName,
onTap: () {
if (c.isHidden()) {
return;

View file

@ -73,14 +73,14 @@ class CollectionPage extends StatelessWidget {
tagPrefix: tagPrefix,
selectedFiles: _selectedFiles,
initialFiles: initialFiles,
albumName: c.collection.name,
albumName: c.collection.displayName,
);
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(50.0),
child: GalleryAppBarWidget(
appBarTypeValue,
c.collection.name,
c.collection.displayName,
_selectedFiles,
collection: c.collection,
),