Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prune mobile model comments

Manav Rathi7f685860f9ef
diff --git a/mobile/apps/auth/lib/models/authenticator/auth_entity.dart b/mobile/apps/auth/lib/models/authenticator/auth_entity.dart
index f5a99cb2d9..7e60392e10 100644
--- a/mobile/apps/auth/lib/models/authenticator/auth_entity.dart
+++ b/mobile/apps/auth/lib/models/authenticator/auth_entity.dart
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
@immutable
class AuthEntity {
final String id;
- // encryptedData will be null for diff items when item is deleted
+ // Null for deleted diff entries.
final String? encryptedData;
final String? header;
final bool isDeleted;
diff --git a/mobile/apps/auth/lib/models/authenticator/local_auth_entity.dart b/mobile/apps/auth/lib/models/authenticator/local_auth_entity.dart
index 723667a767..1e0dc3f325 100644
--- a/mobile/apps/auth/lib/models/authenticator/local_auth_entity.dart
+++ b/mobile/apps/auth/lib/models/authenticator/local_auth_entity.dart
@@ -6,19 +6,16 @@ import 'package:flutter/material.dart';
class LocalAuthEntity {
final int generatedID;
- // id can be null if a code has been scanned locally but it's yet to be
- // synced with the remote server.
+ // Null for scanned codes that have not reached the server.
final String? id;
final String encryptedData;
final String header;
- // createdAt and updateAt will be equal to local time of creation or updation
- // till remote sync is completed.
+ // Local timestamps until remote sync completes.
final int createdAt;
final int updatedAt;
- // shouldSync indicates that the entry was locally created or updated. The
- // app should try to sync it to the server during next sync
+ // True for local changes awaiting remote sync.
final bool shouldSync;
LocalAuthEntity(
diff --git a/mobile/apps/auth/lib/models/code.dart b/mobile/apps/auth/lib/models/code.dart
index 4c47433713..c5c30ab0b7 100644
--- a/mobile/apps/auth/lib/models/code.dart
+++ b/mobile/apps/auth/lib/models/code.dart
@@ -154,8 +154,7 @@ class Code {
);
return code;
} catch (e) {
- // if account name contains # without encoding,
- // rest of the url are treated as url fragment
+ // Retry after encoding an unescaped # in the account name.
if (rawData.contains("#")) {
return Code.fromOTPAuthUrl(
rawData.replaceAll("#", '%23'),
diff --git a/mobile/apps/auth/lib/models/code_display.dart b/mobile/apps/auth/lib/models/code_display.dart
index 0fbc6e00af..63f62e4128 100644
--- a/mobile/apps/auth/lib/models/code_display.dart
+++ b/mobile/apps/auth/lib/models/code_display.dart
@@ -96,7 +96,7 @@ class CodeDisplay {
Logger(
"CodeDisplay",
).severe("Could not parse code display from json", e, s);
- // (ng/prateek) Handle the case where we have fragment in the rawDataUrl
+ // Ignore legacy codeDisplay JSON followed by an unescaped URL fragment.
if (!json.endsWith("}") && json.contains("}#")) {
Logger("CodeDisplay").warning("ignoring code display as it's invalid");
return CodeDisplay();
diff --git a/mobile/apps/auth/lib/services/preference_service.dart b/mobile/apps/auth/lib/services/preference_service.dart
index f81989a5da..42cb24c7f3 100644
--- a/mobile/apps/auth/lib/services/preference_service.dart
+++ b/mobile/apps/auth/lib/services/preference_service.dart
@@ -147,7 +147,7 @@ class PreferenceService {
}
}
- // This is used to adjust the time for TOTP calculations when device local time is not in sync with actual time.
+ // Offset TOTP calculations when the device clock is wrong.
int timeOffsetInMilliSeconds() {
return _prefs.getInt(kLocalTimeOffsetKey) ?? 0;
}
diff --git a/mobile/apps/auth/lib/ui/components/selection_action_button.dart b/mobile/apps/auth/lib/ui/components/selection_action_button.dart
index 2f97d2add3..00f6d6f916 100644
--- a/mobile/apps/auth/lib/ui/components/selection_action_button.dart
+++ b/mobile/apps/auth/lib/ui/components/selection_action_button.dart
@@ -145,7 +145,7 @@ class __BodyState extends State<_Body> {
Text(
widget.labelText,
textAlign: TextAlign.center,
- //textTheme in [getWidthOfLongestWord] should be same as this
+ // Keep this style in sync with getWidthOfWidestWord.
style: getEnteTextTheme(context).miniMuted,
),
],
@@ -187,7 +187,7 @@ class __BodyState extends State<_Body> {
textDirection: TextDirection.ltr,
textScaler: MediaQuery.textScalerOf(context),
)..layout();
- //buffer of 8 added as width is shorter than actual text width
+ // Add 8 points because TextPainter under-measures this label.
return textPainter.size.width + 8;
}
}
diff --git a/mobile/apps/auth/lib/ui/settings/data/import/two_fas_import.dart b/mobile/apps/auth/lib/ui/settings/data/import/two_fas_import.dart
index c5b6f71cad..e320ea2ab5 100644
--- a/mobile/apps/auth/lib/ui/settings/data/import/two_fas_import.dart
+++ b/mobile/apps/auth/lib/ui/settings/data/import/two_fas_import.dart
@@ -149,7 +149,6 @@ String decrypt2FasVault(dynamic data, {required String password}) {
final encryptedData = base64.decode(split[0]);
final salt = base64.decode(split[1]);
final iv = base64.decode(split[2]);
- // derive 256 key using PBKDF2WithHmacSHA256 and 10000 iterations and above salt
final pbkdf2 = PBKDF2KeyDerivator(HMac(SHA256Digest(), 64));
final params = Pbkdf2Parameters(salt, iterationCount, keySize ~/ 8);
pbkdf2.init(params);
diff --git a/mobile/apps/locker/lib/services/collections/collections_service.dart b/mobile/apps/locker/lib/services/collections/collections_service.dart
index e413d9bebc..eceee2cd47 100644
--- a/mobile/apps/locker/lib/services/collections/collections_service.dart
+++ b/mobile/apps/locker/lib/services/collections/collections_service.dart
@@ -588,9 +588,7 @@ class CollectionService {
final Map<int, List<EnteFile>> collectionToFilesMap = await _db
.getAllFilesGroupByCollectionID(uploadedIDs);
- // Find and map the files from current collection to to entries in other
- // collections. This mapping is done to avoid moving all the files to
- // uncategorized during remove from album.
+ // Preserve another album membership instead of moving to Uncategorized.
for (MapEntry<int, List<EnteFile>> entry in collectionToFilesMap.entries) {
if (!await _isAutoMoveCandidate(
collection.id,
diff --git a/mobile/apps/locker/lib/services/collections/models/collection.dart b/mobile/apps/locker/lib/services/collections/models/collection.dart
index c5843a4ded..ba617b855a 100644
--- a/mobile/apps/locker/lib/services/collections/models/collection.dart
+++ b/mobile/apps/locker/lib/services/collections/models/collection.dart
@@ -22,9 +22,6 @@ class Collection {
final int updationTime;
final bool isDeleted;
- // decryptedPath will be null for collections now owned by user, deleted
- // collections, && collections which don't have a path. The path is used
- // to map local on-device album on mobile to remote collection on ente.
String? decryptedPath;
String? mMdEncodedJson;
String? mMdPubEncodedJson;
diff --git a/mobile/apps/locker/lib/services/collections/models/collection_magic.dart b/mobile/apps/locker/lib/services/collections/models/collection_magic.dart
index 8f5ad2ecee..2a93ac57ae 100644
--- a/mobile/apps/locker/lib/services/collections/models/collection_magic.dart
+++ b/mobile/apps/locker/lib/services/collections/models/collection_magic.dart
@@ -12,20 +12,12 @@ const muteKey = "mute";
const orderKey = "order";
class CollectionMagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden
+ // 0 = visible, 1 = archived, 2 = hidden.
int visibility;
- // null/0 value -> no subType
- // 1 -> DEFAULT_HIDDEN COLLECTION for files hidden individually
- // 2 -> Collections created for sharing selected files
int? subType;
- /* order is initially just used for pinned collections.
- Later it can be used for custom sort order for if needed.
- Higher the value, higher the preference of the collection to show up first.
- */
+ // Higher values give a collection higher display priority.
int? order;
CollectionMagicMetadata({required this.visibility, this.subType, this.order});
@@ -86,12 +78,9 @@ class CollectionPubMagicMetadata {
}
class ShareeMagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden etc?
+ // 0 = visible, 1 = archived, 2 = hidden.
int visibility;
- // null/false value -> no mute
bool? mute;
ShareeMagicMetadata({required this.visibility, this.mute});
diff --git a/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart b/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart
index 8f94103bfa..f0b7afb2ce 100644
--- a/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart
+++ b/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart
@@ -20,9 +20,7 @@ const offsetTimeKey = 'offsetTime';
const infoKey = 'info';
class MagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden etc?
+ // 0 = visible, 1 = archived, 2 = hidden.
int visibility;
MagicMetadata({required this.visibility});
@@ -52,30 +50,22 @@ class PubMagicMetadata {
// If this is set, then the file is a streaming version of the original file.
int? sv;
- // ISO 8601 datetime without timezone. This contains the date and time of the photo in the original tz
- // where the photo was taken.
+ // ISO 8601 datetime without an offset, using the photo's original timezone.
String? dateTime;
String? offsetTime;
- // Motion Video Index. Positive value (>0) indicates that the file is a motion
- // photo
+ // A positive Motion Video Index marks a motion photo.
int? mvi;
- // if true, then the thumbnail is not available
- // Note: desktop/web sets hasStaticThumbnail in the file metadata.
- // As we don't want to support updating the og file metadata (yet), adding
- // this new field to the pub metadata. For static thumbnail, all thumbnails
- // should have exact same hash with should match the constant `blackThumbnailBase64`
+ // Mobile stores missing-thumbnail state in public metadata. Desktop and web
+ // use hasStaticThumbnail in file metadata. Missing thumbnails use
+ // blackThumbnailBase64.
bool? noThumb;
- // null -> not computed
- // 0 -> normal
- // 1 -> panorama
+ // null = unknown, 0 = normal, 1 = panorama.
int? mediaType;
- // JSON containing information data for info files.
- // Locker currently writes camelCase type values
- // (note, physicalRecord, accountCredential, emergencyContact).
+ // Locker writes camelCase info type names in this JSON.
Map<String, dynamic>? info;
PubMagicMetadata({
diff --git a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
index a32f3e3b77..1a5dd99083 100644
--- a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
+++ b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
@@ -502,7 +502,6 @@ class FileUploader {
String encryptedFilePath,
String encryptedThumbnailPath,
) async {
- // Note: Consider removing source file if upload has completed / failed
if (File(encryptedFilePath).existsSync()) {
await File(encryptedFilePath).delete();
}
@@ -642,7 +641,6 @@ class FileUploader {
} else if (statusCode == 426) {
_onStorageLimitExceeded();
} else if (attempt < kMaximumUploadAttempts && statusCode == -1) {
- // retry when DioException contains no response/status code
_logger.info("Upload failed, will retry in 3 seconds");
await Future.delayed(const Duration(seconds: 3));
return _uploadFile(
diff --git a/mobile/apps/locker/lib/services/trash/models/trash_file.dart b/mobile/apps/locker/lib/services/trash/models/trash_file.dart
index 50537e7ac7..a199957044 100644
--- a/mobile/apps/locker/lib/services/trash/models/trash_file.dart
+++ b/mobile/apps/locker/lib/services/trash/models/trash_file.dart
@@ -1,14 +1,12 @@
import 'package:locker/services/files/sync/models/file.dart';
class TrashFile extends EnteFile {
- // time when file was put in the trash for first time
+ // Time first moved to Trash.
late int createdAt;
- // for non-deleted trash items, updateAt is usually equal to the latest time
- // when the file was moved to trash
+ // Most recent move to Trash for active entries.
late int updateAt;
- // time after which will will be deleted from trash & user's storage usage
- // will go down
+ // Time when deletion frees the user's storage.
late int deleteBy;
}
diff --git a/mobile/apps/locker/lib/ui/pages/base_info_page.dart b/mobile/apps/locker/lib/ui/pages/base_info_page.dart
index 0f6ff3d199..eac5592d38 100644
--- a/mobile/apps/locker/lib/ui/pages/base_info_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/base_info_page.dart
@@ -318,8 +318,6 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
});
refreshUIWithCurrentData();
-
- // The info file service already performs a sync, so we don't need to sync again
}
Future<void> _updateCollectionMembership() async {
@@ -347,10 +345,8 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
await FavoritesService.instance.addToFavorites(widget.existingFile!);
}
- // Only favorites is special-cased; Uncategorized is treated as a normal
- // collection. A file can belong to multiple collections (incl.
- // Uncategorized), so it is only removed from Uncategorized when the user
- // explicitly deselects it.
+ // Only Favorites is special. Uncategorized changes only when selected or
+ // deselected like any other collection.
final regularCurrentIds = currentCollectionIds
.where((id) => id != favoriteCollection.id)
.toSet();
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index c36fe6322a..8c0f796b6b 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -481,10 +481,7 @@ class _HomePageState extends UploaderPageState<HomePage>
var collections = await CollectionService.instance.getCollections();
await _loadRecentFiles(collections);
- // If collections are empty and first sync is complete, ensure default
- // collections are created. This handles the case where default collections
- // setup was skipped during initialization due to the master key not being
- // available yet.
+ // Create defaults if initialization ran before the master key was ready.
final hasCompletedFirstSync = CollectionService.instance
.hasCompletedFirstSync();
if (collections.isEmpty && hasCompletedFirstSync) {
diff --git a/mobile/apps/photos/lib/core/constants.dart b/mobile/apps/photos/lib/core/constants.dart
index 561b2821e5..07d2b1d312 100644
--- a/mobile/apps/photos/lib/core/constants.dart
+++ b/mobile/apps/photos/lib/core/constants.dart
@@ -39,7 +39,6 @@ const dragSensitivity = 8;
const supportEmail = '[email protected]';
-// this is the chunk size of the un-encrypted file which is read and encrypted before uploading it as a single part.
const multipartPartSize = 20 * 1024 * 1024;
const kDefaultProductionEndpoint = 'https://api.ente.com';
diff --git a/mobile/apps/photos/lib/data/holidays.dart b/mobile/apps/photos/lib/data/holidays.dart
index 617587f08f..cc38934a37 100644
--- a/mobile/apps/photos/lib/data/holidays.dart
+++ b/mobile/apps/photos/lib/data/holidays.dart
@@ -8,8 +8,7 @@ class HolidayData {
HolidayData(this.name, {required this.month, required this.day});
}
-// Based on the locale, this return holidays that have fixed date as per the
-// Gregorian calendar. For example, Christmas is always on December 25th.
+// Returns locale-specific holidays with fixed Gregorian dates.
List<HolidayData> getHolidays(BuildContext context) {
final locale = Localizations.localeOf(context);
if (localeToHolidays.containsKey(locale.toLanguageTag())) {
diff --git a/mobile/apps/photos/lib/db/device_files_db.dart b/mobile/apps/photos/lib/db/device_files_db.dart
index 953e6c2929..5c83da4973 100644
--- a/mobile/apps/photos/lib/db/device_files_db.dart
+++ b/mobile/apps/photos/lib/db/device_files_db.dart
@@ -263,11 +263,7 @@ extension DeviceFiles on FilesDB {
'$existingPathIds',
);
for (String pathID in existingPathIds) {
- // do not delete device collection entries for paths which are
- // marked for backup. This is to handle "Free up space"
- // feature, where we delete files which are backed up. Deleting such
- // entries here result in us losing out on the information that
- // those folders were marked for automatic backup.
+ // Keep folder backup settings after Free up space deletes their files.
final deletedRows = await db.execute(
'''
DELETE FROM device_collections WHERE id = ? AND should_backup = $_sqlBoolFalse
diff --git a/mobile/apps/photos/lib/emergency/model.dart b/mobile/apps/photos/lib/emergency/model.dart
index 836ccd6965..5568165f4d 100644
--- a/mobile/apps/photos/lib/emergency/model.dart
+++ b/mobile/apps/photos/lib/emergency/model.dart
@@ -88,16 +88,12 @@ class EmergencyContact {
}
class EmergencyInfo {
- // List of emergency contacts added by the user
final List<EmergencyContact> contacts;
- // List of recovery sessions that are created to recover current user account
final List<RecoverySessions> recoverSessions;
- // List of emergency contacts that have added current user as their emergency contact
final List<EmergencyContact> othersEmergencyContact;
- // List of recovery sessions that are created to recover grantor's account
final List<RecoverySessions> othersRecoverySession;
EmergencyInfo(
diff --git a/mobile/apps/photos/lib/events/diff_sync_complete_event.dart b/mobile/apps/photos/lib/events/diff_sync_complete_event.dart
index 756af5c578..185db82824 100644
--- a/mobile/apps/photos/lib/events/diff_sync_complete_event.dart
+++ b/mobile/apps/photos/lib/events/diff_sync_complete_event.dart
@@ -1,5 +1,4 @@
import "package:photos/events/event.dart";
-// Creating a separate Event since modifying SyncStatusUpdateEvent has impact on
-// StatusBarWidget
+// Separate from SyncStatusUpdateEvent, which also drives StatusBarWidget.
class DiffSyncCompleteEvent extends Event {}
diff --git a/mobile/apps/photos/lib/gateways/entity/models/data.dart b/mobile/apps/photos/lib/gateways/entity/models/data.dart
index 691ab0edc9..14cca6d9f3 100644
--- a/mobile/apps/photos/lib/gateways/entity/models/data.dart
+++ b/mobile/apps/photos/lib/gateways/entity/models/data.dart
@@ -6,7 +6,7 @@ import "package:freezed_annotation/freezed_annotation.dart";
class EntityData {
final String id;
- // encryptedData will be null for diff items when item is deleted
+ // Null for deleted diff entries.
final String? encryptedData;
final String? header;
final bool isDeleted;
diff --git a/mobile/apps/photos/lib/models/collection/collection.dart b/mobile/apps/photos/lib/models/collection/collection.dart
index 0da75bd934..ea03f2cd57 100644
--- a/mobile/apps/photos/lib/models/collection/collection.dart
+++ b/mobile/apps/photos/lib/models/collection/collection.dart
@@ -17,8 +17,7 @@ class Collection {
// Deprecated but required for old accounts. Use collectionName.
String? name;
- // encryptedName & nameDecryptionNonce will be null for collections
- // created before we started encrypting collection name
+ // Legacy collections may have only the plaintext name.
final String? encryptedName;
final String? nameDecryptionNonce;
final CollectionType type;
@@ -29,14 +28,10 @@ class Collection {
final int? sharedAt;
final bool isDeleted;
- // In early days before public launch, we used to store collection name
- // un-encrypted. decryptName will be value either decrypted value for
- // encryptedName or name itself.
+ // Falls back to the legacy plaintext name.
String? decryptedName;
- // decryptedPath will be null for collections now owned by user, deleted
- // collections, && collections which don't have a path. The path is used
- // to map local on-device album on mobile to remote collection on ente.
+ // Links a user-owned remote collection to its on-device album.
String? decryptedPath;
String? mMdEncodedJson;
String? mMdPubEncodedJson;
@@ -74,7 +69,7 @@ class Collection {
return decryptedName ?? name ?? "Unnamed Album";
}
- // set the value for both name and decryptedName till we finish migration
+ // Keep the legacy name in sync until its migration is complete.
void setName(String newName) {
// ignore: deprecated_member_use_from_same_package
name = newName;
diff --git a/mobile/apps/photos/lib/models/duplicate_files.dart b/mobile/apps/photos/lib/models/duplicate_files.dart
index af97e132c9..f991d34b93 100644
--- a/mobile/apps/photos/lib/models/duplicate_files.dart
+++ b/mobile/apps/photos/lib/models/duplicate_files.dart
@@ -57,7 +57,6 @@ class DuplicateFiles {
DuplicateFiles(this.files, this.size, this.collectionIDs) {
sortByCollectionName();
}
- // sortByLocalIDs sorts the files such that files with localID are at the top
List<EnteFile> sortByLocalIDs() {
final List<EnteFile> filesWithoutLocalID = [];
final List<EnteFile> localFiles = [];
diff --git a/mobile/apps/photos/lib/models/file/extensions/file_props.dart b/mobile/apps/photos/lib/models/file/extensions/file_props.dart
index 1f89f14c29..8d07bdea12 100644
--- a/mobile/apps/photos/lib/models/file/extensions/file_props.dart
+++ b/mobile/apps/photos/lib/models/file/extensions/file_props.dart
@@ -18,7 +18,6 @@ extension FilePropsExtn on EnteFile {
bool get hasDims => height > 0 && width > 0;
- // return true if the file can be a panorama image, null if the dimensions are not available
bool? isPanorama() {
if (fileType != FileType.image) {
return false;
diff --git a/mobile/apps/photos/lib/models/file/trash_file.dart b/mobile/apps/photos/lib/models/file/trash_file.dart
index dddd1de6c2..f62ecbfccc 100644
--- a/mobile/apps/photos/lib/models/file/trash_file.dart
+++ b/mobile/apps/photos/lib/models/file/trash_file.dart
@@ -5,8 +5,6 @@ sealed class TrashFile extends EnteFile {
TrashFile.from(super.file, {required this.deleteBy}) : super.from();
- // time after which will will be deleted from trash & user's storage usage
- // will go down
late int deleteBy;
}
@@ -22,8 +20,6 @@ class EnteTrashFile extends TrashFile {
late int createdAt;
- // for non-deleted trash items, updateAt is usually equal to the latest time
- // when the file was moved to trash
late int updateAt;
}
diff --git a/mobile/apps/photos/lib/models/freeable_space_info.dart b/mobile/apps/photos/lib/models/freeable_space_info.dart
index f97f83c380..6484266a9f 100644
--- a/mobile/apps/photos/lib/models/freeable_space_info.dart
+++ b/mobile/apps/photos/lib/models/freeable_space_info.dart
@@ -8,9 +8,7 @@ class FreeableSpaceInfo {
class FreeableFileIDs {
final List<String> localIDs;
final List<int> uploadedIDs;
- // localSize indicates the approximate size of the files on the device.
- // The size may not be exact because the remoteFile is encrypted before
- // uploaded
+ // Approximate device size; the stored size is for the encrypted upload.
final int localSize;
FreeableFileIDs(this.localIDs, this.uploadedIDs, this.localSize);
diff --git a/mobile/apps/photos/lib/models/gallery_type.dart b/mobile/apps/photos/lib/models/gallery_type.dart
index 1f0d8f0017..a84bb0bb6f 100644
--- a/mobile/apps/photos/lib/models/gallery_type.dart
+++ b/mobile/apps/photos/lib/models/gallery_type.dart
@@ -5,8 +5,7 @@ enum GalleryType {
homepage,
archive,
uncategorized,
- // hidden section shows all the files that are present in the defaultHidden
- // collections.
+ // Files from every default-hidden collection.
hiddenSection,
hiddenOwnedCollection,
favorite,
diff --git a/mobile/apps/photos/lib/models/location/location.dart b/mobile/apps/photos/lib/models/location/location.dart
index f0a298a12b..1a7cc430a8 100644
--- a/mobile/apps/photos/lib/models/location/location.dart
+++ b/mobile/apps/photos/lib/models/location/location.dart
@@ -28,10 +28,6 @@ abstract class Location with _$Location {
return true;
}
- // isValidRange checks if the latitude and longitude are within the valid range
- // for latitude and longitude. Note: We are only checking the range while
- // rending location on the map. We need to investigate in which cases we are
- // parsing incorrect location value.
static bool isValidRange({
required double latitude,
required double longitude,
diff --git a/mobile/apps/photos/lib/models/metadata/collection_magic.dart b/mobile/apps/photos/lib/models/metadata/collection_magic.dart
index 418a73d999..96274d2ced 100644
--- a/mobile/apps/photos/lib/models/metadata/collection_magic.dart
+++ b/mobile/apps/photos/lib/models/metadata/collection_magic.dart
@@ -15,20 +15,12 @@ const albumDescriptionKey = "caption";
const maxAlbumDescriptionLength = 200;
class CollectionMagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden
+ // 0 = visible, 1 = archived, 2 = hidden.
int visibility;
- // null/0 value -> no subType
- // 1 -> DEFAULT_HIDDEN COLLECTION for files hidden individually
- // 2 -> Collections created for sharing selected files
int? subType;
- /* order is initially just used for pinned collections.
- Later it can be used for custom sort order for if needed.
- Higher the value, higher the preference of the collection to show up first.
- */
+ // Higher values give a collection higher display priority.
int? order;
CollectionMagicMetadata({required this.visibility, this.subType, this.order});
@@ -107,17 +99,12 @@ class CollectionPubMagicMetadata {
}
class ShareeMagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden etc?
+ // 0 = visible, 1 = archived, 2 = hidden.
int visibility;
- // null/false value -> no mute
bool? mute;
- /* order is used for pinned collections for sharees.
- Higher the value, higher the preference of the collection to show up first.
- */
+ // Higher values give a collection higher display priority.
int? order;
ShareeMagicMetadata({required this.visibility, this.mute, this.order});
diff --git a/mobile/apps/photos/lib/models/metadata/file_magic.dart b/mobile/apps/photos/lib/models/metadata/file_magic.dart
index 547cf452bc..b00b1d8e92 100644
--- a/mobile/apps/photos/lib/models/metadata/file_magic.dart
+++ b/mobile/apps/photos/lib/models/metadata/file_magic.dart
@@ -26,9 +26,7 @@ String formatPubMagicDateTime(DateTime dateTime) {
}
class MagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden etc?
+ // 0 = visible, 1 = archived, 2 = hidden.
int visibility;
MagicMetadata({required this.visibility});
@@ -60,25 +58,19 @@ class PubMagicMetadata {
// If this is set, then the file is a streaming version of the original file.
int? sv;
- // ISO 8601 datetime without timezone. This contains the date and time of the photo in the original tz
- // where the photo was taken.
+ // ISO 8601 datetime without an offset, using the photo's original timezone.
String? dateTime;
String? offsetTime;
- // Motion Video Index. Positive value (>0) indicates that the file is a motion
- // photo
+ // A positive Motion Video Index marks a motion photo.
int? mvi;
- // if true, then the thumbnail is not available
- // Note: desktop/web sets hasStaticThumbnail in the file metadata.
- // As we don't want to support updating the og file metadata (yet), adding
- // this new field to the pub metadata. For static thumbnail, all thumbnails
- // should have exact same hash with should match the constant `blackThumbnailBase64`
+ // Mobile stores missing-thumbnail state in public metadata. Desktop and web
+ // use hasStaticThumbnail in file metadata. Missing thumbnails use
+ // blackThumbnailBase64.
bool? noThumb;
- // null -> not computed
- // 0 -> normal
- // 1 -> panorama
+ // null = unknown, 0 = normal, 1 = panorama.
int? mediaType;
PubMagicMetadata({
diff --git a/mobile/apps/photos/lib/models/ml/face/face.dart b/mobile/apps/photos/lib/models/ml/face/face.dart
index c9036d99ab..855adb62ef 100644
--- a/mobile/apps/photos/lib/models/ml/face/face.dart
+++ b/mobile/apps/photos/lib/models/ml/face/face.dart
@@ -92,8 +92,8 @@ class Face {
);
}
- // Note: Keep the information in toJson minimum. Keep in sync with desktop.
- // Derive fields like fileID from other values whenever possible
+ // Keep toJson minimal and in sync with desktop. Derive fields such as fileID
+ // from the serialized values.
Map<String, dynamic> toJson() => {
'faceID': faceID,
'embedding': embedding,
diff --git a/mobile/apps/photos/lib/models/ml/face/face_with_embedding.dart b/mobile/apps/photos/lib/models/ml/face/face_with_embedding.dart
index 2fcd30f4c0..e655685b18 100644
--- a/mobile/apps/photos/lib/models/ml/face/face_with_embedding.dart
+++ b/mobile/apps/photos/lib/models/ml/face/face_with_embedding.dart
@@ -36,8 +36,8 @@ class FaceWithoutEmbedding {
);
}
- // Note: Keep the information in toJson minimum. Keep in sync with desktop.
- // Derive fields like fileID from other values whenever possible
+ // Keep toJson minimal and in sync with desktop. Derive fields such as fileID
+ // from the serialized values.
Map<String, dynamic> toJson() => {
'faceID': faceID,
'detection': detection.toJson(),
diff --git a/mobile/apps/photos/lib/module/download/thumbnail.dart b/mobile/apps/photos/lib/module/download/thumbnail.dart
index 2f323643a5..a31367d50a 100644
--- a/mobile/apps/photos/lib/module/download/thumbnail.dart
+++ b/mobile/apps/photos/lib/module/download/thumbnail.dart
@@ -101,8 +101,7 @@ preloadThumbnailWithPendingRequestRef(EnteFile file) async {
);
}
-// Note: This method should only be called for files that have been uploaded
-// since cachedThumbnailPath depends on the file's uploadedID
+// cachedThumbnailPath requires an uploaded file ID.
Future<File?> getThumbnailForUploadedFile(EnteFile file) async {
final cachedThumbnail = cachedThumbnailPath(file);
if (await cachedThumbnail.exists()) {
@@ -111,7 +110,7 @@ Future<File?> getThumbnailForUploadedFile(EnteFile file) async {
}
final thumbnail = await getThumbnail(file);
if (thumbnail != null) {
- // it might be already written to this path during `getThumbnail(file)`
+ // getThumbnail may have already written this path.
if (!await cachedThumbnail.exists()) {
final didWrite = await _writeCachedThumbnail(
cachedThumbnail,
@@ -379,7 +378,7 @@ Future<void> _downloadAndDecryptThumbnail(_ThumbnailDownload item) async {
}
ThumbnailInMemoryLruCache.put(item.file, data);
final cachedThumbnail = cachedThumbnailPath(item.file);
- // data is already cached in-memory, no need to await on disk write
+ // The in-memory cache makes the disk write non-blocking.
unawaited(_writeCachedThumbnail(cachedThumbnail, data));
if (!item.completer.isCompleted) {
item.completer.complete(data);
diff --git a/mobile/apps/photos/lib/module/upload/upload_data.dart b/mobile/apps/photos/lib/module/upload/upload_data.dart
index 432e3ba5aa..2f31dc055d 100644
--- a/mobile/apps/photos/lib/module/upload/upload_data.dart
+++ b/mobile/apps/photos/lib/module/upload/upload_data.dart
@@ -241,8 +241,7 @@ Future<Uint8List?> _getThumbnailForUpload(
}
}
-// check if the assetType is still the same. This can happen for livePhotos
-// if the user turns off the video using native photos app
+// iOS Photos can turn a Live Photo into a regular image after import.
void _assertFileType(AssetEntity asset, EnteFile file) {
final assetType = fileTypeFromAsset(asset);
if (assetType == file.fileType) {
diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dart
index ea804e2c2f..9836b4d2d9 100644
--- a/mobile/apps/photos/lib/services/collections_service.dart
+++ b/mobile/apps/photos/lib/services/collections_service.dart
@@ -1014,18 +1014,15 @@ class CollectionsService {
Future<void> trashEmptyCollection(
Collection collection, {
- // during bulk deletion, this event is not fired to avoid quick refresh
- // of the collection gallery
+ // Avoid rapid gallery refreshes during bulk deletion.
bool isBulkDelete = false,
}) async {
try {
if (!isBulkDelete) {
await _turnOffDeviceFolderSync(collection);
}
- // While trashing empty albums, we must pass keepFiles flag as True.
- // The server will verify that the collection is actually empty before
- // deleting the files. If keepFiles is set as False and the collection
- // is not empty, then the files in the collections will be moved to trash.
+ // keepFiles makes the server reject deletion unless the album is empty;
+ // false would trash any files still in it.
await collectionsGateway.deleteCollection(
collectionID: collection.id,
keepFiles: true,
@@ -1220,8 +1217,7 @@ class CollectionsService {
Future<void> rename(Collection collection, String newName) async {
try {
- // Note: when collection created to sharing few files is renamed
- // convert that collection to a regular collection type.
+ // Renaming a quick-share album makes it a regular album.
if (collection.isQuickLinkCollection()) {
await updateMagicMetadata(collection, {"subType": 0});
}
@@ -1281,8 +1277,7 @@ class CollectionsService {
utf8.encode(jsonEncode(jsonToUpdate)),
key,
);
- // for required field, the json validator on golang doesn't treat 0 as valid
- // value. Instead of changing version to ptr, decided to start version with 1.
+ // Go's required-field validation rejects version 0.
final int currentVersion = max(collection.mMdVersion, 1);
final params = UpdateMagicMetadataRequest(
id: collection.id,
@@ -1333,8 +1328,7 @@ class CollectionsService {
utf8.encode(jsonEncode(jsonToUpdate)),
key,
);
- // for required field, the json validator on golang doesn't treat 0 as valid
- // value. Instead of changing version to ptr, decided to start version with 1.
+ // Go's required-field validation rejects version 0.
final int currentVersion = max(collection.mMbPubVersion, 1);
final params = UpdateMagicMetadataRequest(
id: collection.id,
@@ -1389,8 +1383,7 @@ class CollectionsService {
utf8.encode(jsonEncode(jsonToUpdate)),
key,
);
- // for required field, the json validator on golang doesn't treat 0 as valid
- // value. Instead of changing version to ptr, decided to start version with 1.
+ // Go's required-field validation rejects version 0.
final int currentVersion = max(collection.sharedMmdVersion, 1);
final params = UpdateMagicMetadataRequest(
id: collection.id,
diff --git a/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart
index b65e063f7d..84533eaac3 100644
--- a/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart
+++ b/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart
@@ -589,7 +589,6 @@ class PersonService {
Bus.instance.fire(PeopleChangedEvent());
}
- // Returns true when remote changes were downloaded or newly applied locally.
Future<bool> _pullAndApplyRemotePersons({
bool skipClusterUpdateIfNoChange = true,
}) async {
diff --git a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart b/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
index 27ce419515..e12448bf21 100644
--- a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
+++ b/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
@@ -198,8 +198,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
children: [
const SizedBox(height: 12),
Visibility(
- // hidden textForm for suggesting auto-fill service for saving
- // password
+ // A hidden password field prompts autofill to save the password.
visible: false,
child: TextFormField(
autofillHints: const [AutofillHints.email],
diff --git a/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dart
index d4f184eed0..323216af53 100644
--- a/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dart
+++ b/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dart
@@ -649,9 +649,7 @@ class CollectionActions {
}
}
- // Find and map the files from current collection to to entries in other
- // collections. This mapping is done to avoid moving all the files to
- // uncategorized during remove from album.
+ // Preserve another album membership instead of moving to Uncategorized.
for (MapEntry<int, List<EnteFile>> entry in collectionToFilesMap.entries) {
if (!_isAutoMoveCandidate(collection.id, entry.key, currentUserID)) {
continue;
diff --git a/mobile/apps/photos/lib/ui/payment/subscription.dart b/mobile/apps/photos/lib/ui/payment/subscription.dart
index 750fac0ae7..2396b5cf3c 100644
--- a/mobile/apps/photos/lib/ui/payment/subscription.dart
+++ b/mobile/apps/photos/lib/ui/payment/subscription.dart
@@ -15,10 +15,7 @@ StatefulWidget getSubscriptionPage({bool isOnBoarding = false}) {
}
}
-// return true if the user was created after we added support for stripe payment
-// on frame. We do this check to avoid showing Stripe payment option for earlier
-// users who might have paid via playStore. This method should be removed once
-// we have better handling for active play/app store subscription & stripe plans.
+// Older users may have an active Play/App Store subscription.
bool _isUserCreatedPostStripeSupport() {
return Configuration.instance.getUserID()! > 1580559962386460;
}
diff --git a/mobile/apps/photos/lib/utils/delete_file_util.dart b/mobile/apps/photos/lib/utils/delete_file_util.dart
index 996ee9ba58..9f42df8cd9 100644
--- a/mobile/apps/photos/lib/utils/delete_file_util.dart
+++ b/mobile/apps/photos/lib/utils/delete_file_util.dart
@@ -77,7 +77,7 @@ Future<List<EnteFile>> deleteFilesFromEverywhere(
_logger.info("Trying to deleteFilesFromEverywhere " + files.toString());
final List<String> localAssetIDs = [];
final List<String> localSharedMediaIDs = [];
- final List<String> alreadyDeletedIDs = []; // Files already missing from disk.
+ final List<String> alreadyDeletedIDs = [];
bool hasLocalOnlyFiles = false;
for (final file in files) {
if (file.localID != null) {
@@ -228,7 +228,7 @@ Future<List<EnteFile>> deleteFilesOnDeviceOnly(
_logger.info("Trying to deleteFilesOnDeviceOnly" + files.toString());
final List<String> localAssetIDs = [];
final List<String> localSharedMediaIDs = [];
- final List<String> alreadyDeletedIDs = []; // Files already missing from disk.
+ final List<String> alreadyDeletedIDs = [];
final localOnlyIDs = <String?>{};
for (final file in files) {
if (file.localID != null) {
diff --git a/mobile/apps/photos/lib/utils/magic_util.dart b/mobile/apps/photos/lib/utils/magic_util.dart
index 8a87531f40..9ee0ca4466 100644
--- a/mobile/apps/photos/lib/utils/magic_util.dart
+++ b/mobile/apps/photos/lib/utils/magic_util.dart
@@ -105,8 +105,7 @@ Future<void> changeCollectionVisibility(
update,
);
}
- // Force reload home gallery to pull in/remove the now visibility changed
- // files
+ // Reload so the home gallery adds or removes the collection's files.
Bus.instance.fire(
ForceReloadHomeGalleryEvent(
"CollectionVisibilityChange: $visibilityAction",
diff --git a/mobile/apps/photos/lib/utils/network_util.dart b/mobile/apps/photos/lib/utils/network_util.dart
index fca32e1029..41582e1c4f 100644
--- a/mobile/apps/photos/lib/utils/network_util.dart
+++ b/mobile/apps/photos/lib/utils/network_util.dart
@@ -2,8 +2,7 @@ import "package:connectivity_plus/connectivity_plus.dart";
import "package:photos/service_locator.dart";
Future<bool> canUseHighBandwidth() async {
- // Connections will contain a list of currently active connections.
- // could be vpn and wifi or mobile and vpn, but should not be wifi and mobile
+ // A VPN can be reported alongside Wi-Fi or mobile.
final List<ConnectivityResult> connections = await (Connectivity()
.checkConnectivity());
bool canUploadUnderCurrentNetworkConditions = true;
diff --git a/mobile/apps/photos/lib/utils/share_util.dart b/mobile/apps/photos/lib/utils/share_util.dart
index cb4070ee4f..da38bc761d 100644
--- a/mobile/apps/photos/lib/utils/share_util.dart
+++ b/mobile/apps/photos/lib/utils/share_util.dart
@@ -37,9 +37,8 @@ Future<void> share(
try {
final List<Future<String?>> pathFutures = [];
for (EnteFile file in files) {
- // Note: We are requesting the origin file for performance reasons on iOS.
- // This will eat up storage, which will be reset only when the app restarts.
- // We could have cleared the cache had there been a callback to the share API.
+ // iOS origin files are faster to share but remain cached until restart;
+ // the share API has no completion callback for cleanup.
pathFutures.add(
getFile(file, isOrigin: true).then((fetchedFile) {
final path = fetchedFile?.path;
diff --git a/mobile/packages/lock_screen/lib/lock_screen_settings.dart b/mobile/packages/lock_screen/lib/lock_screen_settings.dart
index b7d076d0fa..0ccf02d656 100644
--- a/mobile/packages/lock_screen/lib/lock_screen_settings.dart
+++ b/mobile/packages/lock_screen/lib/lock_screen_settings.dart
@@ -302,9 +302,7 @@ class LockScreenSettings {
return _preferences.setBool(keyShouldShowLockScreen, value);
}
- // If the app was uninstalled (without logging out if it was used with
- // backups), keychain items of the app persist in the keychain. To avoid using
- // old keychain items, we delete them on reinstall.
+ // Keychain entries survive uninstall, so clear them after a reinstall.
Future<void> _clearLsDataInKeychainIfFreshInstall(
bool hasOptedForOfflineMode,
) async {