This commit updates the ViewModel classes for both Chat and Task to accommodate the new structured responses received from the API. These changes are essential for the correct functioning of the application as they deal with the new TaskResponse and Step objects.
Updates in ChatViewModel:
- Modified `fetchChatsForTask` to handle structured step data
- Updated how steps are retrieved and processed
Updates in TaskViewModel:
- Updated `fetchTasks` to use the new TaskResponse object
- Refactored task fetching and selection logic
These updates ensure that the ViewModel classes are aligned with the new structured API responses, improving data handling and UI updates.
This commit refactors the ChatViewModel to use the newly created ChatService and Step model for chat-related functionalities. The changes include:
- Replaced mock data source with real API calls via ChatService.
- Introduced _currentTaskId to keep track of the current task ID.
- Added fetchChatsForTask method to fetch steps related to the current task and populate the chat list.
- Implemented sendChatMessage to execute a step and add both user and agent messages to the chat list.
By making these changes, the ChatViewModel is now fully integrated with the backend services and models, thus enabling a more realistic and dynamic chat experience.
This commit introduces the ChatViewModel, which manages the business logic for chat interactions associated with tasks. The ViewModel communicates with a mock data source, offering functionalities like fetching chats for a specific task and sending chat messages.
In addition to the implementation, comprehensive tests for ChatViewModel have been provided to ensure its behavior is consistent with our design goals and expectations.
Key Features:
Chat management in ChatViewModel.
Tests covering all major functionalities of ChatViewModel.
Mock data source updates to emulate chat data interactions.