chore: migrate to new Hive

Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
TheOneWithTheBraid 2022-07-22 17:06:50 +02:00
parent 3194348958
commit 5b9daebcf9
7 changed files with 60 additions and 14 deletions

3
.gitignore vendored
View File

@ -42,6 +42,9 @@ lib/generated_plugin_registrant.dart
docs/build/
docs/.jekyll-cache/
docs/_site/
web/worker.js
web/worker.js.map
web/worker.js.deps
# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

View File

@ -7,6 +7,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/utils/client_manager.dart';
import '../../widgets/matrix.dart';
import 'settings_emotes_view.dart';
@ -206,7 +207,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
);
try {
file = (await file.generateThumbnail(
compute: Matrix.of(context).client.runInBackground,
nativeImplementations: ClientManager.nativeImplementations,
))!;
} catch (_) {
// do nothing

View File

@ -16,11 +16,20 @@ import 'matrix_sdk_extensions.dart/fluffybox_database.dart';
abstract class ClientManager {
static const String clientNamespace = 'im.fluffychat.store.clients';
/// the expected native implementations for the device
static final nativeImplementations = kIsWeb
? NativeImplementationsWebWorker(Uri.parse('native_executor.js'))
: NativeImplementationsIsolate(compute);
static Future<List<Client>> getClients({bool initialize = true}) async {
if (PlatformInfos.isLinux) {
Hive.init((await getApplicationSupportDirectory()).path);
} else {
await Hive.initFlutter();
await Hive.initFlutter(
null,
HiveStorageBackendPreference.webWorker('worker.js'),
);
}
final clientNames = <String>{};
try {
@ -109,7 +118,7 @@ abstract class ClientManager {
PlatformInfos.isMacOS)
AuthenticationTypes.sso
},
compute: compute,
nativeImplementations: nativeImplementations,
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
);
}

View File

@ -262,6 +262,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
cryptography:
dependency: transitive
description:
name: cryptography
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
csslib:
dependency: transitive
description:
@ -493,6 +500,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.1+3"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
fluffybox:
dependency: transitive
description:
@ -834,18 +848,22 @@ packages:
source: hosted
version: "0.7.0"
hive:
dependency: transitive
dependency: "direct overridden"
description:
name: hive
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
path: hive
ref: cacfc53dc1114491eaa3d3f3842312db910c1330
resolved-ref: cacfc53dc1114491eaa3d3f3842312db910c1330
url: "https://github.com/hivedb/hive.git"
source: git
version: "2.2.3"
hive_flutter:
dependency: "direct main"
description:
name: hive_flutter
url: "https://pub.dartlang.org"
source: hosted
path: hive_flutter
ref: cacfc53dc1114491eaa3d3f3842312db910c1330
resolved-ref: cacfc53dc1114491eaa3d3f3842312db910c1330
url: "https://github.com/hivedb/hive.git"
source: git
version: "1.1.0"
html:
dependency: transitive
@ -1063,7 +1081,7 @@ packages:
name: matrix
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.0"
version: "0.11.1"
matrix_api_lite:
dependency: transitive
description:
@ -1240,7 +1258,7 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.11"
path_provider_android:
dependency: transitive
description:

View File

@ -61,7 +61,7 @@ dependencies:
keyboard_shortcuts: ^0.1.4
localstorage: ^4.0.0+1
lottie: ^1.2.2
matrix: ^0.11.0
matrix: ^0.11.1
matrix_homeserver_recommendations: ^0.2.1
matrix_link_text: ^1.0.2
native_imaging:
@ -160,6 +160,16 @@ dependency_overrides:
hosted:
name: geolocator_android
url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
hive:
git:
url: https://github.com/hivedb/hive.git
path: hive
ref: cacfc53dc1114491eaa3d3f3842312db910c1330
hive_flutter:
git:
url: https://github.com/hivedb/hive.git
path: hive_flutter
ref: cacfc53dc1114491eaa3d3f3842312db910c1330
# waiting for null safety
# Upstream pull request: https://github.com/AntoineMarcel/keyboard_shortcuts/pull/13
keyboard_shortcuts:

View File

@ -3,3 +3,5 @@ flutter config --enable-web
flutter clean
flutter pub get
flutter build web --release --verbose --source-maps
dart compile js ./web/worker.dart -o ./web/worker.js -m

3
web/worker.dart Normal file
View File

@ -0,0 +1,3 @@
import 'package:hive/hive.dart';
main() => startWebWorker();