From c83bfee7cc81552fcd6a716723d6d0e786e704e2 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Fri, 2 Aug 2024 10:20:06 +0300 Subject: [PATCH] feat(app): Server changed to dev2 --- lib/core/constants/constants.dart | 2 +- .../initialization_cubit.dart | 23 +++++++++++++------ .../bloc/chat_room_cubit/chat_room_cubit.dart | 21 ++++++++++++----- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/lib/core/constants/constants.dart b/lib/core/constants/constants.dart index c0353c4..4daf523 100644 --- a/lib/core/constants/constants.dart +++ b/lib/core/constants/constants.dart @@ -1 +1 @@ -const String baseUrl = 'https://mobile-stage.eatvio.ru'; +const String baseUrl = 'https://dev2.eatvio.ru'; diff --git a/lib/core/initialization_cubit/initialization_cubit.dart b/lib/core/initialization_cubit/initialization_cubit.dart index 4a1bcaf..dd06a97 100644 --- a/lib/core/initialization_cubit/initialization_cubit.dart +++ b/lib/core/initialization_cubit/initialization_cubit.dart @@ -11,13 +11,18 @@ class InitializationCubit extends Cubit { final ChatRepository chatRepository; bool wasInitialized = false; - InitializationCubit({required this.chatRepository}) : super(const InitializationState.loading()); + InitializationCubit({required this.chatRepository}) + : super(const InitializationState.loading()); - Future subscribeNotifications(int userId, PusherChannelsClient client) async { + Future subscribeNotifications( + int userId, PusherChannelsClient client) async { final privateNotificationChannel = await client.privateChannel( 'private-message-events.$userId', - authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel( - authorizationEndpoint: Uri.parse('https://mobile-stage.eatvio.ru/broadcasting/auth'), + authorizationDelegate: + EndpointAuthorizableChannelTokenAuthorizationDelegate + .forPrivateChannel( + authorizationEndpoint: + Uri.parse('https://dev2.eatvio.ru/broadcasting/auth'), headers: { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, @@ -31,11 +36,15 @@ class InitializationCubit extends Cubit { }); } - Future subscribeChatMessages(int userId, PusherChannelsClient client) async { + Future subscribeChatMessages( + int userId, PusherChannelsClient client) async { final privateMessagesChannel = await client.privateChannel( 'private-new-chat-messages.$userId', - authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel( - authorizationEndpoint: Uri.parse('https://mobile-stage.eatvio.ru/broadcasting/auth'), + authorizationDelegate: + EndpointAuthorizableChannelTokenAuthorizationDelegate + .forPrivateChannel( + authorizationEndpoint: + Uri.parse('https://dev2.eatvio.ru/broadcasting/auth'), headers: { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, diff --git a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart index 3773c43..49ab767 100644 --- a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart +++ b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart @@ -39,12 +39,16 @@ class ChatRoomCubit extends Cubit { )); try { - final chatMessages = await chatRepository.getChatMessages(chatId, currentPage + 1); + final chatMessages = + await chatRepository.getChatMessages(chatId, currentPage + 1); isLoading = false; emit(ChatRoomState.loaded( chatRoom: (state as ChatRoomStateLoaded).chatRoom, - chatMessages: [...(state as ChatRoomStateLoaded).chatMessages, ...chatMessages.messagesList], + chatMessages: [ + ...(state as ChatRoomStateLoaded).chatMessages, + ...chatMessages.messagesList + ], isTyping: (state as ChatRoomStateLoaded).isTyping, isLoading: isLoading, )); @@ -61,10 +65,12 @@ class ChatRoomCubit extends Cubit { try { final chatRoom = await chatRepository.getChatRoom(chatId); - final chatMessages = await chatRepository.getChatMessages(chatId, currentPage); + final chatMessages = + await chatRepository.getChatMessages(chatId, currentPage); lastPage = chatMessages.meta.lastPage; - await subscribeToChatChannel(initCubit: initializationCubit, chatId: chatId); + await subscribeToChatChannel( + initCubit: initializationCubit, chatId: chatId); emit(ChatRoomState.loaded( chatRoom: chatRoom, @@ -86,8 +92,11 @@ class ChatRoomCubit extends Cubit { privateChatChannel = await client.privateChannel( 'private-direct-chat.$chatId', - authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel( - authorizationEndpoint: Uri.parse('https://mobile-stage.eatvio.ru/broadcasting/auth'), + authorizationDelegate: + EndpointAuthorizableChannelTokenAuthorizationDelegate + .forPrivateChannel( + authorizationEndpoint: + Uri.parse('https://dev2.eatvio.ru/broadcasting/auth'), headers: { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', },