feat(app): Server changed to dev2

This commit is contained in:
2024-08-02 10:20:06 +03:00
parent c9f293159e
commit c83bfee7cc
3 changed files with 32 additions and 14 deletions

View File

@@ -1 +1 @@
const String baseUrl = 'https://mobile-stage.eatvio.ru';
const String baseUrl = 'https://dev2.eatvio.ru';

View File

@@ -11,13 +11,18 @@ class InitializationCubit extends Cubit<InitializationState> {
final ChatRepository chatRepository;
bool wasInitialized = false;
InitializationCubit({required this.chatRepository}) : super(const InitializationState.loading());
InitializationCubit({required this.chatRepository})
: super(const InitializationState.loading());
Future<void> subscribeNotifications(int userId, PusherChannelsClient client) async {
Future<void> 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<InitializationState> {
});
}
Future<void> subscribeChatMessages(int userId, PusherChannelsClient client) async {
Future<void> 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()}',
},

View File

@@ -39,12 +39,16 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
));
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<ChatRoomState> {
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<ChatRoomState> {
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()}',
},