diff --git a/lib/chat_room/cubit/chat_room_cubit.dart b/lib/chat_room/cubit/chat_room_cubit.dart index ed0f11279..3b3bed2e3 100644 --- a/lib/chat_room/cubit/chat_room_cubit.dart +++ b/lib/chat_room/cubit/chat_room_cubit.dart @@ -292,7 +292,8 @@ abstract class ChatRoomCubit extends Cubit { helpCenterOptions.customNotification != null && helpCenterOptions.customNotification! && helpCenterOptions.customNotificationRoom != null) { - invites.add(helpCenterOptions.customNotificationRoom!); + _roomId = await matrixChat + .joinRoom(helpCenterOptions.customNotificationRoom!); } } else { //roomIdStoredKey == SecureStorageKeys.chatSupportRoomId @@ -303,13 +304,12 @@ abstract class ChatRoomCubit extends Cubit { } else { invites.add(AltMeStrings.matrixChatSupportId); } + _roomId = await matrixChat.createRoomAndInviteSupport( + tokenParameters.thumbprint, + invites, + ); } - _roomId = await matrixChat.createRoomAndInviteSupport( - tokenParameters.thumbprint, - invites, - ); - await matrixChat.setRoomIdInStorage(roomIdStoredKey, _roomId!); _getUnreadMessageCount(); await _subscribeToEventsOfRoom(); diff --git a/lib/chat_room/matrix_chat/matrix_chat_impl.dart b/lib/chat_room/matrix_chat/matrix_chat_impl.dart index 43e7be5ba..9376b65f0 100644 --- a/lib/chat_room/matrix_chat/matrix_chat_impl.dart +++ b/lib/chat_room/matrix_chat/matrix_chat_impl.dart @@ -467,6 +467,22 @@ class MatrixChatImpl extends MatrixChatInterface { } } + /// join room with [roomName] + @override + Future joinRoom(String roomName) async { + try { + if (client == null) { + await _initClient(); + } + final roomId = await client!.joinRoom(roomName); + await enableRoomEncyption(roomId); + return roomId; + } catch (e, s) { + logger.e('e: $e, s: $s'); + throw Exception(); + } + } + @override String getThumbnail({ required String url, diff --git a/lib/chat_room/matrix_chat/matrix_chat_interface.dart b/lib/chat_room/matrix_chat/matrix_chat_interface.dart index b5e9f6107..f7c9638d3 100644 --- a/lib/chat_room/matrix_chat/matrix_chat_interface.dart +++ b/lib/chat_room/matrix_chat/matrix_chat_interface.dart @@ -19,6 +19,7 @@ abstract class MatrixChatInterface { String roomName, List? invites, ); + Future joinRoom(String roomName); Future enableRoomEncyption(String roomId); Future handleImageSelection({ required OnMessageCreated onMessageCreated, diff --git a/lib/enterprise/cubit/enterprise_cubit.dart b/lib/enterprise/cubit/enterprise_cubit.dart index c98239979..afcc1eda7 100644 --- a/lib/enterprise/cubit/enterprise_cubit.dart +++ b/lib/enterprise/cubit/enterprise_cubit.dart @@ -507,6 +507,16 @@ class EnterpriseCubit extends Cubit { // ); // } + final helpCenterOptions = profileSetting.helpCenterOptions; + + if (helpCenterOptions.displayNotification != null && + helpCenterOptions.displayNotification! && + helpCenterOptions.customNotification != null && + helpCenterOptions.customNotification! && + helpCenterOptions.customNotificationRoom != null) { + await matrixNotificationCubit.init(); + } + emit( state.copyWith( status: AppStatus.success,