فهرست منبع

Rename DBHelper

Vishnu Mohandas 5 سال پیش
والد
کامیت
496e1d2f81

+ 3 - 3
lib/db/db_helper.dart → lib/db/photo_db.dart

@@ -5,7 +5,7 @@ import 'package:path/path.dart';
 import 'package:sqflite/sqflite.dart';
 import 'package:path_provider/path_provider.dart';
 
-class DatabaseHelper {
+class PhotoDB {
   static final _databaseName = "ente.db";
   static final _databaseVersion = 1;
 
@@ -22,8 +22,8 @@ class DatabaseHelper {
   static final columnSyncTimestamp = 'sync_timestamp';
 
   // make this a singleton class
-  DatabaseHelper._privateConstructor();
-  static final DatabaseHelper instance = DatabaseHelper._privateConstructor();
+  PhotoDB._privateConstructor();
+  static final PhotoDB instance = PhotoDB._privateConstructor();
 
   // only have a single app-wide reference to the database
   static Database _database;

+ 2 - 2
lib/face_search_manager.dart

@@ -1,6 +1,6 @@
 import 'package:dio/dio.dart';
 import 'package:photos/core/configuration.dart';
-import 'package:photos/db/db_helper.dart';
+import 'package:photos/db/photo_db.dart';
 import 'package:logging/logging.dart';
 
 import 'package:photos/models/face.dart';
@@ -37,7 +37,7 @@ class FaceSearchManager {
               headers: {"X-Auth-Token": Configuration.instance.getToken()}),
         )
         .then((response) => (response.data["results"] as List)
-            .map((result) => (DatabaseHelper.instance.getPhotoByPath(result))));
+            .map((result) => (PhotoDB.instance.getPhotoByPath(result))));
     return Future.wait(await futures);
   }
 

+ 2 - 2
lib/photo_repository.dart

@@ -1,6 +1,6 @@
 import 'package:logging/logging.dart';
 import 'package:photos/core/event_bus.dart';
-import 'package:photos/db/db_helper.dart';
+import 'package:photos/db/photo_db.dart';
 import 'package:photos/events/local_photos_updated_event.dart';
 import 'package:photos/models/photo.dart';
 
@@ -16,7 +16,7 @@ class PhotoRepository {
   }
 
   Future<bool> loadPhotos() async {
-    DatabaseHelper db = DatabaseHelper.instance;
+    PhotoDB db = PhotoDB.instance;
     var photos = await db.getAllPhotos();
 
     _photos.clear();

+ 2 - 2
lib/photo_sync_manager.dart

@@ -4,7 +4,7 @@ import 'dart:math';
 
 import 'package:logging/logging.dart';
 import 'package:photos/core/event_bus.dart';
-import 'package:photos/db/db_helper.dart';
+import 'package:photos/db/photo_db.dart';
 import 'package:photos/events/user_authenticated_event.dart';
 import 'package:photos/photo_repository.dart';
 import 'package:photos/photo_provider.dart';
@@ -20,7 +20,7 @@ import 'package:photos/events/remote_sync_event.dart';
 class PhotoSyncManager {
   final _logger = Logger("PhotoSyncManager");
   final _dio = Dio();
-  final _db = DatabaseHelper.instance;
+  final _db = PhotoDB.instance;
   bool _isSyncInProgress = false;
 
   static final _lastSyncTimestampKey = "last_sync_timestamp_0";

+ 5 - 6
lib/ui/device_folders_gallery_widget.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
-import 'package:photos/db/db_helper.dart';
+import 'package:photos/db/photo_db.dart';
 import 'package:photos/favorite_photos_repository.dart';
 import 'package:photos/models/device_folder.dart';
 import 'package:photos/models/filters/favorite_items_filter.dart';
@@ -57,10 +57,10 @@ class _DeviceFolderGalleryWidgetState extends State<DeviceFolderGalleryWidget> {
   }
 
   Future<List<DeviceFolder>> _getDeviceFolders() async {
-    final paths = await DatabaseHelper.instance.getDistinctPaths();
+    final paths = await PhotoDB.instance.getDistinctPaths();
     final folders = List<DeviceFolder>();
     for (final path in paths) {
-      final photo = await DatabaseHelper.instance.getLatestPhotoInPath(path);
+      final photo = await PhotoDB.instance.getLatestPhotoInPath(path);
       final folderName = p.basename(path);
       folders
           .add(DeviceFolder(folderName, photo, FolderNameFilter(folderName)));
@@ -70,9 +70,8 @@ class _DeviceFolderGalleryWidgetState extends State<DeviceFolderGalleryWidget> {
           .compareTo(first.thumbnailPhoto.createTimestamp);
     });
     if (FavoritePhotosRepository.instance.hasFavorites()) {
-      final photo = await DatabaseHelper.instance
-          .getLatestPhotoAmongGeneratedIds(
-              FavoritePhotosRepository.instance.getLiked().toList());
+      final photo = await PhotoDB.instance.getLatestPhotoAmongGeneratedIds(
+          FavoritePhotosRepository.instance.getLiked().toList());
       folders.insert(
           0, DeviceFolder("Favorites", photo, FavoriteItemsFilter()));
     }

+ 3 - 3
lib/ui/gallery_app_bar_widget.dart

@@ -2,7 +2,7 @@ import 'dart:async';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:photos/core/event_bus.dart';
-import 'package:photos/db/db_helper.dart';
+import 'package:photos/db/photo_db.dart';
 import 'package:photos/events/remote_sync_event.dart';
 import 'package:photos/models/photo.dart';
 import 'package:photos/photo_repository.dart';
@@ -153,8 +153,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
 
     for (Photo photo in widget.selectedPhotos) {
       deleteEverywhere
-          ? await DatabaseHelper.instance.markPhotoForDeletion(photo)
-          : await DatabaseHelper.instance.deletePhoto(photo);
+          ? await PhotoDB.instance.markPhotoForDeletion(photo)
+          : await PhotoDB.instance.deletePhoto(photo);
     }
     Navigator.of(context, rootNavigator: true).pop();
     PhotoRepository.instance.reloadPhotos();