fetchMessagesFromGrpc function

ThunkAction<ChatState> fetchMessagesFromGrpc(
  1. String conversationId
)

Implementation

ThunkAction<ChatState> fetchMessagesFromGrpc(String conversationId) {

  return (Store<ChatState> store) async {
    store.dispatch(SetLoadingAction(true));

    try {


      final response = await chatService.getMessages(conversationId = conversationId);
      final messages = response;  // List<Message_text>

      store.dispatch(LoadMessagesAction(messages));
    } catch (e) {
      store.dispatch(SetErrorAction(e.toString()));
    } finally {
      store.dispatch(SetLoadingAction(false));
    }
  };
}