Commit afa6d311 authored by Wilko Manger's avatar Wilko Manger

Update Matrix SDK and run in seperate isolate

parent 3988ffef
......@@ -40,10 +40,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
Stream<AuthState> mapEventToState(AuthEvent event) async* {
if (event is Check) {
final user = await MyUser.fromStore(
Matrix.store,
await Matrix.storeLocation,
roomIds: _chatOrderBloc.state.personal.keys.take(10).followedBy(
_chatOrderBloc.state.public.keys.take(10),
),
isolated: true,
);
print('user.rooms: ${user?.rooms?.length}');
......
......@@ -23,19 +23,22 @@ import 'package:matrix_sdk/matrix_sdk.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import 'package:moor/moor.dart';
import 'package:moor_ffi/moor_ffi.dart';
import 'package:path/path.dart' as path;
import 'auth/bloc.dart';
import 'models/chat.dart';
class Matrix {
static final MoorStore store = MoorStore(
LazyDatabase(() async {
final dataDir = await getApplicationDocumentsDirectory();
return VmDatabase(File(path.join(dataDir.path, 'pattle.sqlite')));
}),
);
static MoorStore _store;
static MoorStore get store => _store;
static Future<MoorStoreLocation> get storeLocation async {
final dataDir = await getApplicationDocumentsDirectory();
return MoorStoreLocation.file(
File(path.join(dataDir.path, 'pattle.sqlite')),
);
}
// Used for listening to auth state changes
final AuthBloc _authBloc;
......
......@@ -307,7 +307,7 @@ Future<void> _handleBackgroundMessage(Map<String, dynamic> message) async {
await completer.future;
} else {
final user = await MyUser.fromStore(Matrix.store);
final user = await MyUser.fromStore(await Matrix.storeLocation);
data = await NotificationData.fromDataMessage(
DataMessage.fromJson(message),
......
......@@ -69,7 +69,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
@override
ChatState get initialState => _loadMessages(
chat: _chat,
delta: Room(),
delta: _room.delta(),
becauseOfTimelineLoad: false,
);
......
......@@ -58,10 +58,11 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
final user = await state.homeserverState.value.login(
state.usernameState.value,
event.password,
store: Matrix.store,
store: await Matrix.storeLocation,
device: Device(
name: 'Pattle ${Platform.isAndroid ? 'Android' : 'iOS'}',
),
isolated: true,
);
_startBloc.add(ProgressToNextStep());
......
......@@ -26,7 +26,7 @@ extension UrlResolver on Uri {
bool thumbnail = false,
}) {
return toHttpsWith(
Matrix.of(context).user.context.homeserver,
Matrix.of(context).user.context.updater.homeserver,
thumbnail: thumbnail,
);
}
......
......@@ -309,8 +309,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "5d4e68a4413ff1283cbbe56d4e31a7c22d2b53aa"
resolved-ref: "5d4e68a4413ff1283cbbe56d4e31a7c22d2b53aa"
ref: "397752c584d3f62f796aa61b80519c86167a0cba"
resolved-ref: "397752c584d3f62f796aa61b80519c86167a0cba"
url: "https://git.pattle.im/pattle/library/matrix-dart-sdk.git"
source: git
version: "0.0.0"
......@@ -341,14 +341,14 @@ packages:
name: moor
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "3.0.2"
moor_ffi:
dependency: transitive
description:
name: moor_ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0"
version: "0.5.0"
nested:
dependency: transitive
description:
......@@ -525,7 +525,7 @@ packages:
source: hosted
version: "1.7.0"
sqflite:
dependency: "direct main"
dependency: transitive
description:
name: sqflite
url: "https://pub.dartlang.org"
......
......@@ -13,7 +13,8 @@ dependencies:
matrix_sdk:
git:
url: https://git.pattle.im/pattle/library/matrix-dart-sdk.git
ref: 5d4e68a4413ff1283cbbe56d4e31a7c22d2b53aa
ref: 397752c584d3f62f796aa61b80519c86167a0cba
async: ^2.3.0
bloc: ^3.0.0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment