From c5412d0c10d304a74c7e7959346335a7bd377c2b Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 20 May 2020 07:10:13 +0000 Subject: [PATCH] Update .gitlab-ci.yml Deleted assets/js/package/olm.js --- .gitlab-ci.yml | 7 ++++--- assets/js/package/olm.js | 2 +- lib/components/matrix.dart | 2 +- lib/utils/famedlysdk_store.dart | 20 ++++++++++++++----- lib/utils/firebase_controller.dart | 3 +-- pubspec.lock | 31 ++++++++++++------------------ pubspec.yaml | 2 +- 7 files changed, 35 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bef17a56..8bbb1aaa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,9 +27,10 @@ build_web: - sudo apt update - sudo apt install curl -y - rm -r assets/js/package - - cd assets/js/ && curl -O 'https://janian.de/index.php/s/ZKpQi4xFkGWPMHQ/download' && cd ../../ - - cd assets/js/ && mv download olm.tar.gz && cd ../../ - - cd assets/js/ && tar xaf olm.tar.gz && cd ../../ + - cd assets/js/ && curl -L 'https://gitlab.com/famedly/libraries/olm/-/jobs/artifacts/master/download?job=build_js' > olm.zip && cd ../../ + - cd assets/js/ && unzip olm.zip && cd ../../ + - cd assets/js/ && rm olm.zip && cd ../../ + - cd assets/js/ && mv javascript package && cd ../../ - flutter pub get - flutter clean - flutter build web --release --verbose --dart-define=FLUTTER_WEB_USE_SKIA=true diff --git a/assets/js/package/olm.js b/assets/js/package/olm.js index 0c399d16..a0a08e3d 100644 --- a/assets/js/package/olm.js +++ b/assets/js/package/olm.js @@ -1 +1 @@ -// Dummy file \ No newline at end of file +// Dummy file :-) diff --git a/lib/components/matrix.dart b/lib/components/matrix.dart index d6e6b908..6151c2bb 100644 --- a/lib/components/matrix.dart +++ b/lib/components/matrix.dart @@ -74,7 +74,7 @@ class MatrixState extends State { void _initWithStore() async { var initLoginState = client.onLoginStateChanged.stream.first; - client.database = await getDatabase(client, store); + client.database = await getDatabase(client); client.connect(); if (await initLoginState == LoginState.logged && !kIsWeb) { await FirebaseController.setupFirebase( diff --git a/lib/utils/famedlysdk_store.dart b/lib/utils/famedlysdk_store.dart index 8b0a9c95..761b64e6 100644 --- a/lib/utils/famedlysdk_store.dart +++ b/lib/utils/famedlysdk_store.dart @@ -11,25 +11,29 @@ import './database/shared.dart'; import 'package:olm/olm.dart' as olm; // needed for migration import 'package:random_string/random_string.dart'; -Future getDatabase(Client client, Store store) async { +Future getDatabase(Client client) async { + if (_db != null) return _db; + final store = Store(); var password = await store.getItem('database-password'); var needMigration = false; if (password == null || password.isEmpty) { needMigration = true; password = randomString(255); } - final db = constructDb( + _db = constructDb( logStatements: false, filename: 'moor.sqlite', password: password, ); if (needMigration) { - await migrate(client.clientName, db, store); + await migrate(client.clientName, _db, store); await store.setItem('database-password', password); } - return db; + return _db; } +Database _db; + Future migrate(String clientName, Database db, Store store) async { debugPrint('[Store] attempting old migration to moor...'); final oldKeys = await store.getAllItems(); @@ -147,7 +151,13 @@ Future migrate(String clientName, Database db, Store store) async { devices = List.from(json.decode(devicesString)); } await db.storeOutboundGroupSession( - clientId, roomId, pickle, json.encode(devices)); + clientId, + roomId, + pickle, + json.encode(devices), + DateTime.now(), + 0, + ); } // session_keys final sessionKeysMatch = diff --git a/lib/utils/firebase_controller.dart b/lib/utils/firebase_controller.dart index 41e127fb..07020e69 100644 --- a/lib/utils/firebase_controller.dart +++ b/lib/utils/firebase_controller.dart @@ -151,8 +151,7 @@ abstract class FirebaseController { final platform = kIsWeb ? 'Web' : Platform.operatingSystem; final clientName = 'FluffyChat $platform'; client = Client(clientName, debug: false); - final store = Store(); - client.database = await getDatabase(client, store); + client.database = await getDatabase(client); client.connect(); await client.onLoginStateChanged.stream .firstWhere((l) => l == LoginState.logged) diff --git a/pubspec.lock b/pubspec.lock index 253b3557..bb9d54ad 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -71,13 +71,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.3" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" collection: dependency: transitive description: @@ -136,19 +129,12 @@ packages: url: "https://github.com/simolus3/moor.git" source: git version: "1.0.0" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" famedlysdk: dependency: "direct main" description: path: "." - ref: bb690a22daab54a53a8df8e2dffb87da8a374bb1 - resolved-ref: bb690a22daab54a53a8df8e2dffb87da8a374bb1 + ref: "359e03496ad72f125ae275788621ac4f42d99d01" + resolved-ref: "359e03496ad72f125ae275788621ac4f42d99d01" url: "https://gitlab.com/famedly/famedlysdk.git" source: git version: "0.0.1" @@ -466,10 +452,10 @@ packages: description: path: "." ref: "1.x.y" - resolved-ref: "79868b06b3ea156f90b73abafb3bbf3ac4114cc6" + resolved-ref: f66975bd1b5cb1865eba5efe6e3a392aa5e396a5 url: "https://gitlab.com/famedly/libraries/dart-olm.git" source: git - version: "1.0.0" + version: "1.1.1" open_file: dependency: "direct main" description: @@ -497,7 +483,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.6.4" path_drawing: dependency: transitive description: @@ -575,6 +561,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.4.2" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" random_string: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 4fc397a4..61a4cc55 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: famedlysdk: git: url: https://gitlab.com/famedly/famedlysdk.git - ref: bb690a22daab54a53a8df8e2dffb87da8a374bb1 + ref: 359e03496ad72f125ae275788621ac4f42d99d01 localstorage: ^3.0.1+4 bubble: ^1.1.9+1