Fix: Macht die BackgroundWorker für den IsolateManager on Web möglich
This commit is contained in:
6
lib/PlatformDependent/Native/update_transactions.dart
Normal file
6
lib/PlatformDependent/Native/update_transactions.dart
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import '../../Controller/port_controller.dart';
|
||||||
|
|
||||||
|
/// Aktualisiert die Transaktionen, die angezeigt werden
|
||||||
|
void updateTransactions() {
|
||||||
|
PortController().getPort('update-transactions')?.send('ready');
|
||||||
|
}
|
||||||
19
lib/PlatformDependent/Web/date_utils_web.dart
Normal file
19
lib/PlatformDependent/Web/date_utils_web.dart
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/// Utility functions for working with dates.
|
||||||
|
class DateUtils {
|
||||||
|
/// Returns a [DateTime] that is [monthDate] with the added number
|
||||||
|
/// of months and the day set to 1 and time set to midnight.
|
||||||
|
///
|
||||||
|
/// For example:
|
||||||
|
///
|
||||||
|
/// ```dart
|
||||||
|
/// DateTime date = DateTime(2019, 1, 15);
|
||||||
|
/// DateTime futureDate = DateUtils.addMonthsToMonthDate(date, 3);
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// `date` would be January 15, 2019.
|
||||||
|
/// `futureDate` would be April 1, 2019 since it adds 3 months.
|
||||||
|
static DateTime addMonthsToMonthDate(
|
||||||
|
final DateTime monthDate,
|
||||||
|
final int monthsToAdd,
|
||||||
|
) => DateTime(monthDate.year, monthDate.month + monthsToAdd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/// Ein Stub
|
||||||
|
class LocalNotifications {
|
||||||
|
/// Ein Stub
|
||||||
|
Future<void> showTransactionsToCheckNotification(
|
||||||
|
final List<dynamic> transactions,
|
||||||
|
) async {}
|
||||||
|
}
|
||||||
2
lib/PlatformDependent/Web/update_transactions.dart
Normal file
2
lib/PlatformDependent/Web/update_transactions.dart
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/// Ein Stub
|
||||||
|
void updateTransactions() {}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
|
||||||
/// Initialisiert benötigte Services in Background-Isolates für Web
|
/// Initialisiert benötigte Services in Background-Isolates für PlatformDependent
|
||||||
Future<void> initBackground() async {
|
Future<void> initBackground() async {
|
||||||
Logger().d('Init Background for Web');
|
Logger().d('Init Background for PlatformDependent');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
|
||||||
import '../Controller/port_controller.dart';
|
|
||||||
import '../Controller/transaction_controller.dart';
|
|
||||||
import '../Entities/drift_database.dart';
|
import '../Entities/drift_database.dart';
|
||||||
import '../Entities/time_frame_enum.dart';
|
import '../Entities/time_frame_enum.dart';
|
||||||
|
import '../PlatformDependent/Web/date_utils_web.dart'
|
||||||
|
if (dart.library.io) 'package:flutter/material.dart';
|
||||||
|
import '../PlatformDependent/Web/update_transactions.dart'
|
||||||
|
if (dart.library.io) '../PlatformDependent/Native/update_transactions.dart';
|
||||||
import '../Repositories/recurring_transacation_repository.dart';
|
import '../Repositories/recurring_transacation_repository.dart';
|
||||||
import '../Repositories/transaction_repository.dart';
|
import '../Repositories/transaction_repository.dart';
|
||||||
import 'task.dart';
|
import 'task.dart';
|
||||||
@@ -48,11 +48,7 @@ class GenerateTransactionsTask extends Task {
|
|||||||
|
|
||||||
_logger.i('Generating transactions completed.');
|
_logger.i('Generating transactions completed.');
|
||||||
|
|
||||||
if (!kIsWeb) {
|
updateTransactions();
|
||||||
PortController().getPort('update-transactions')?.send('ready');
|
|
||||||
} else {
|
|
||||||
unawaited(TransactionController().updateTransactions());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
|
||||||
import '../Controller/local_notifications.dart';
|
|
||||||
import '../Entities/drift_database.dart';
|
import '../Entities/drift_database.dart';
|
||||||
|
import '../PlatformDependent/Web/local_notifications_web_stub.dart'
|
||||||
|
if (dart.library.io) '../Controller/local_notifications.dart';
|
||||||
import '../Repositories/transaction_repository.dart';
|
import '../Repositories/transaction_repository.dart';
|
||||||
import 'task.dart';
|
import 'task.dart';
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ class ShowNotificationsTask extends Task {
|
|||||||
|
|
||||||
if (transactions.isNotEmpty) {
|
if (transactions.isNotEmpty) {
|
||||||
Logger().i('Showing notification for unchecked transactions...');
|
Logger().i('Showing notification for unchecked transactions...');
|
||||||
|
|
||||||
await LocalNotifications().showTransactionsToCheckNotification(
|
await LocalNotifications().showTransactionsToCheckNotification(
|
||||||
transactions,
|
transactions,
|
||||||
);
|
);
|
||||||
|
|||||||
1
lib/Web/local_notifications_web_stub.dart
Normal file
1
lib/Web/local_notifications_web_stub.dart
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// TODO Implement this library.
|
||||||
17448
web/runTask.js
17448
web/runTask.js
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user