diff --git a/lib/sync/matrix/matrix_service.dart b/lib/sync/matrix/matrix_service.dart index 4fa3b2e67..a69ac8908 100644 --- a/lib/sync/matrix/matrix_service.dart +++ b/lib/sync/matrix/matrix_service.dart @@ -89,6 +89,7 @@ class MatrixService { Future listen() async { await startKeyVerificationListener(); await listenToTimeline(); + listenToMatrixRoomInvites(service: this); } Client get client => _client; diff --git a/lib/sync/matrix/room.dart b/lib/sync/matrix/room.dart index eacdba7bd..3cf4b9a7a 100644 --- a/lib/sync/matrix/room.dart +++ b/lib/sync/matrix/room.dart @@ -110,3 +110,23 @@ Future inviteToMatrixRoom({ }) async { await service.syncRoom?.invite(userId); } + +void listenToMatrixRoomInvites({ + required MatrixService service, +}) { + final client = service.client; + client.onRoomState.stream.listen((event) async { + final roomIdFromEvent = event.room.id; + if (service.syncRoom?.id == null) { + await saveMatrixRoom( + client: client, + roomId: roomIdFromEvent, + ); + + await joinMatrixRoom( + roomId: roomIdFromEvent, + service: service, + ); + } + }); +} diff --git a/pubspec.yaml b/pubspec.yaml index 6542d406b..312c7e868 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: lotti description: Achieve your goals and keep your data private with Lotti. publish_to: 'none' -version: 0.9.455+2481 +version: 0.9.456+2483 msix_config: display_name: LottiApp