Skip to content

Commit

Permalink
chore: old TODOs (#4758)
Browse files Browse the repository at this point in the history
Deleted files:
* `dao_hive_product.dart`: we don't store products in hive since 18 months ago
* `dao_unzipped_product.dart`: we don't store products as unzipped since 18 months ago

Impacted files:
* `background_task_hunger_games.dart`: impacted by off-dart new features
* `background_task_image.dart`: impacted by off-dart new features
* `crop_page.dart`: impacted by off-dart new features
* `local_database.dart`: removed hive and unzipped products
  • Loading branch information
monsieurtanuki authored Nov 4, 2023
1 parent ca252b3 commit 4ab2150
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class BackgroundTaskHungerGames extends BackgroundTaskBarcode {
@override
Future<void> upload() async {
final InsightAnnotation? annotation =
_getInsightAnnotation(insightAnnotation);
InsightAnnotation.fromInt(insightAnnotation);
if (annotation == null) {
// very unlikely
return;
Expand All @@ -126,15 +126,4 @@ class BackgroundTaskHungerGames extends BackgroundTaskBarcode {
deviceId: OpenFoodAPIConfiguration.uuid,
);
}

// TODO(monsieurtanuki): move to off-dart
static InsightAnnotation? _getInsightAnnotation(final int annotation) {
for (final InsightAnnotation insightAnnotation
in InsightAnnotation.values) {
if (annotation == insightAnnotation.value) {
return insightAnnotation;
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ class BackgroundTaskImage extends BackgroundTaskUpload {
}

// cf. https://github.com/openfoodfacts/smooth-app/issues/4219
// TODO(monsieurtanuki): move to off-dart
static const int minimumWidth = 640;
static const int minimumHeight = 160;

static bool isPictureBigEnough(final num width, final num height) =>
width >= minimumWidth || height >= minimumHeight;
width >= ImageHelper.minimumWidth || height >= ImageHelper.minimumHeight;

/// Adds the background task about uploading a product image.
static Future<void> addTask(
Expand Down
81 changes: 0 additions & 81 deletions packages/smooth_app/lib/database/dao_hive_product.dart

This file was deleted.

160 changes: 0 additions & 160 deletions packages/smooth_app/lib/database/dao_unzipped_product.dart

This file was deleted.

14 changes: 1 addition & 13 deletions packages/smooth_app/lib/database/local_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import 'package:smooth_app/background/background_task_manager.dart';
import 'package:smooth_app/data_models/up_to_date_product_list_provider.dart';
import 'package:smooth_app/data_models/up_to_date_product_provider.dart';
import 'package:smooth_app/database/abstract_dao.dart';
import 'package:smooth_app/database/dao_hive_product.dart';
import 'package:smooth_app/database/dao_instant_string.dart';
import 'package:smooth_app/database/dao_int.dart';
import 'package:smooth_app/database/dao_product.dart';
import 'package:smooth_app/database/dao_product_list.dart';
import 'package:smooth_app/database/dao_product_migration.dart';
import 'package:smooth_app/database/dao_string.dart';
import 'package:smooth_app/database/dao_string_list.dart';
import 'package:smooth_app/database/dao_string_list_map.dart';
import 'package:smooth_app/database/dao_transient_operation.dart';
import 'package:smooth_app/database/dao_unzipped_product.dart';
import 'package:smooth_app/database/dao_work_barcode.dart';
import 'package:sqflite/sqflite.dart';

Expand Down Expand Up @@ -74,7 +71,6 @@ class LocalDatabase extends ChangeNotifier {
// only hive from there
await Hive.initFlutter();
final List<AbstractDao> daos = <AbstractDao>[
DaoHiveProduct(localDatabase),
DaoProductList(localDatabase),
DaoStringList(localDatabase),
DaoString(localDatabase),
Expand All @@ -91,14 +87,7 @@ class LocalDatabase extends ChangeNotifier {
}

// Migrations here
await DaoProductMigration.migrate(
source: DaoHiveProduct(localDatabase),
destination: DaoUnzippedProduct(localDatabase),
);
await DaoProductMigration.migrate(
source: DaoUnzippedProduct(localDatabase),
destination: DaoProduct(localDatabase),
);
// (no migration for the moment)

return localDatabase;
}
Expand All @@ -112,7 +101,6 @@ class LocalDatabase extends ChangeNotifier {
final int oldVersion,
final int newVersion,
) async {
await DaoUnzippedProduct.onUpgrade(db, oldVersion, newVersion);
await DaoProduct.onUpgrade(db, oldVersion, newVersion);
await DaoWorkBarcode.onUpgrade(db, oldVersion, newVersion);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/crop_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ class _CropPageState extends State<CropPage> {
title: appLocalizations.crop_page_too_small_image_title,
body: Text(
appLocalizations.crop_page_too_small_image_message(
BackgroundTaskImage.minimumWidth,
BackgroundTaskImage.minimumHeight,
ImageHelper.minimumWidth,
ImageHelper.minimumHeight,
width,
height,
),
Expand Down

0 comments on commit 4ab2150

Please sign in to comment.