🐛 Fix bugs
This commit is contained in:
@@ -9,12 +9,17 @@ AppDatabase constructDb() {
|
|||||||
DatabaseConnection connectOnWeb() {
|
DatabaseConnection connectOnWeb() {
|
||||||
return DatabaseConnection.delayed(
|
return DatabaseConnection.delayed(
|
||||||
Future(() async {
|
Future(() async {
|
||||||
|
try {
|
||||||
final result = await WasmDatabase.open(
|
final result = await WasmDatabase.open(
|
||||||
databaseName: 'solar_network_data',
|
databaseName: 'solar_network_data',
|
||||||
sqlite3Uri: Uri.parse('sqlite3.wasm'),
|
sqlite3Uri: Uri.parse('sqlite3.wasm'),
|
||||||
driftWorkerUri: Uri.parse('drift_worker.dart.js'),
|
driftWorkerUri: Uri.parse('drift_worker.dart.js'),
|
||||||
);
|
);
|
||||||
return result.resolvedExecutor;
|
return result.resolvedExecutor;
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to open WASM database: $e');
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -312,7 +312,7 @@ class ServerStateNotifier extends StateNotifier<ServerState> {
|
|||||||
: super(ServerState(status: 'Server not started'));
|
: super(ServerState(status: 'Server not started'));
|
||||||
|
|
||||||
Future<void> start() async {
|
Future<void> start() async {
|
||||||
if (!Platform.isAndroid && !Platform.isIOS && !kIsWeb) {
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS) {
|
||||||
try {
|
try {
|
||||||
await server.start();
|
await server.start();
|
||||||
state = state.copyWith(status: 'Server running');
|
state = state.copyWith(status: 'Server running');
|
||||||
|
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
@@ -11,6 +12,10 @@ import 'notify.universal.dart' as universal_notify;
|
|||||||
|
|
||||||
// Platform-specific delegation
|
// Platform-specific delegation
|
||||||
Future<void> initializeLocalNotifications() async {
|
Future<void> initializeLocalNotifications() async {
|
||||||
|
if (kIsWeb) {
|
||||||
|
// No local notifications on web
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
return windows_notify.initializeLocalNotifications();
|
return windows_notify.initializeLocalNotifications();
|
||||||
} else {
|
} else {
|
||||||
@@ -18,10 +23,14 @@ Future<void> initializeLocalNotifications() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSubscription setupNotificationListener(
|
StreamSubscription? setupNotificationListener(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
) {
|
) {
|
||||||
|
if (kIsWeb) {
|
||||||
|
// No notification listener on web
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
return windows_notify.setupNotificationListener(context, ref);
|
return windows_notify.setupNotificationListener(context, ref);
|
||||||
} else {
|
} else {
|
||||||
@@ -33,6 +42,10 @@ Future<void> subscribePushNotification(
|
|||||||
Dio apiClient, {
|
Dio apiClient, {
|
||||||
bool detailedErrors = false,
|
bool detailedErrors = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (kIsWeb) {
|
||||||
|
// No push notification subscription on web
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
return windows_notify.subscribePushNotification(
|
return windows_notify.subscribePushNotification(
|
||||||
apiClient,
|
apiClient,
|
||||||
|
@@ -248,6 +248,8 @@
|
|||||||
src="https://unpkg.com/sweetalert@2.1.2/dist/sweetalert.min.js"
|
src="https://unpkg.com/sweetalert@2.1.2/dist/sweetalert.min.js"
|
||||||
async=""
|
async=""
|
||||||
></script>
|
></script>
|
||||||
|
<!-- Drift WASM -->
|
||||||
|
<script src="drift_worker.dart.js"></script>
|
||||||
<!-- Sign in with Apple -->
|
<!-- Sign in with Apple -->
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
|
Reference in New Issue
Block a user