Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Calendar Optimization and IcalRepository Integration #41

Merged
merged 29 commits into from
Oct 17, 2024

Conversation

othbcq
Copy link
Contributor

@othbcq othbcq commented Oct 15, 2024

Description

This PR implements various optimizations and new features for the calendar functionality in the application. The key changes are as follows:

  • IcalRepository Integration: Introduced IcalRepository interface and implemented HttpIcalRepository and MockIcalRepository classes to handle calendar data fetching. This allows for better testing and flexibility in data retrieval methods.

  • CalendarViewModel Refactor: Updated CalendarViewModel to use the repository pattern for fetching iCal data. This includes:

    • Replacing the use of OkHttpClient within the ViewModel with IcalRepository.
    • Creating a companion object with a ViewModelProvider.Factory for easier instantiation.
    • Switched from using mutableStateListOf<VEvent>() to MutableStateFlow<List<VEvent>>. This ensures proper handling of state updates and aligns with the best practices for managing UI state in Jetpack Compose.
  • CalendarViewModel Tests: Added comprehensive unit tests for CalendarViewModel to cover:

    • Filtering and sorting of events.
    • Proper handling of recurring and multi-day events.
    • Edge case handling (e.g., events spanning the start or end of the testing period).
  • Improved Testing: Added unit tests for CalendarScreen and ensured mock data is used via MockIcalRepository. Refactored test cases to accommodate the repository changes and ensure proper test coverage.

  • UI Enhancements:

    • Refined calendar navigation with better icons and buttons.
    • Minor improvements to CalendarScreen layout to enhance user experience.
  • Bug Fixes: Addressed several issues related to event parsing, including proper handling of recurring and non-recurring events.

@othbcq othbcq self-assigned this Oct 15, 2024
@othbcq othbcq linked an issue Oct 15, 2024 that may be closed by this pull request
Othmane Bencheqroun added 18 commits October 16, 2024 20:37
- Implement tests for handling multi-day non-recurring events.
- Add tests for events without an end date.
- Ensure events outside the date range are ignored.
- Test recurring events with multiple instances.
- Include tests for empty calendar data.
- Validate the application handles malformed iCal data without crashing.
- Added tests for Calendar navigation buttons (previous/next month)
- Added tests for event search dialog functionality (open, search, cancel)
- Improved event item display test with correct title and date verification
- Optimized test structure and removed redundant logic
…oud warning

Improved handling of side effects by replacing let with also.
- Added exception handling in fetchICalData() for IOException and general exceptions.
- Ensures proper logging and stable app state in case of network or other fetch-related failures.
- Prevents app crashes due to network issues or unexpected errors during iCal data fetching.
- Added tests to ensure IOException and general exceptions are handled correctly in fetchICalData().
- Validated that CalendarViewModel state remains stable and empty in case of network failures or parsing errors.
- Increased test coverage for edge cases in exception handling.
- Added tests to verify proper handling of IOException, ParserException, and general exceptions.
- Ensured parseICalData catches errors correctly and sets icalEvents to an empty list.
- Improved overall test coverage for CalendarViewModel error scenarios.
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
75.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@Kenzoud Kenzoud self-requested a review October 17, 2024 16:56
Copy link
Contributor

@Kenzoud Kenzoud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is well-structured and reflects the TA's recommended changes from the last review. Everything looks good from my side.

@othbcq othbcq merged commit cf90432 into main Oct 17, 2024
1 of 2 checks passed
@AdrienBousquieEPFL AdrienBousquieEPFL deleted the feature/calendar-optimization branch October 17, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Calendar's Code and Optimize UI
2 participants