< Summary

Class:PlacesAndEventsSectionComponentController
Assembly:ExploreV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/PlacesAndEventsSectionComponentController.cs
Covered lines:32
Uncovered lines:0
Coverable lines:32
Total lines:100
Line coverage:100% (32 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PlacesAndEventsSectionComponentController(...)0%110100%
RequestExploreV2Closing()0%220100%
GoToEventsSubSection()0%110100%
Dispose()0%110100%
PlacesAndEventsVisibleChanged(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/PlacesAndEventsSectionComponentController.cs

#LineLine coverage
 1using DCL;
 2using ExploreV2Analytics;
 3using System;
 4using DCL.Social.Friends;
 5
 6public interface IPlacesAndEventsSectionComponentController : IDisposable
 7{
 8    /// <summary>
 9    /// It will be triggered when the section want to request to close the ExploreV2 main menu.
 10    /// </summary>
 11    event Action<bool> OnCloseExploreV2;
 12}
 13
 14public class PlacesAndEventsSectionComponentController : IPlacesAndEventsSectionComponentController
 15{
 16    internal const float MIN_TIME_TO_CHECK_API = 60f;
 17
 18    public event Action<bool> OnCloseExploreV2;
 19
 20    internal IPlacesAndEventsSectionComponentView view;
 21    internal IHighlightsSubSectionComponentController highlightsSubSectionComponentController;
 22    internal IPlacesSubSectionComponentController placesSubSectionComponentController;
 23    internal IEventsSubSectionComponentController eventsSubSectionComponentController;
 24    internal IFavoritesSubSectionComponentController favoritesSubSectionComponentController;
 25    private DataStore dataStore;
 26
 1827    internal BaseVariable<bool> placesAndEventsVisible => dataStore.exploreV2.placesAndEventsVisible;
 28
 629    public PlacesAndEventsSectionComponentController(
 30        IPlacesAndEventsSectionComponentView view,
 31        IExploreV2Analytics exploreV2Analytics,
 32        DataStore dataStore)
 33    {
 634        this.view = view;
 635        this.dataStore = dataStore;
 36
 637        PlacesAPIController placesAPI = new PlacesAPIController();
 638        EventsAPIController eventsAPI = new EventsAPIController();
 39
 640        highlightsSubSectionComponentController = new HighlightsSubSectionComponentController(
 41            view.HighlightsSubSectionView,
 42            placesAPI,
 43            eventsAPI,
 44            FriendsController.i,
 45            exploreV2Analytics,
 46            dataStore);
 647        highlightsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 648        highlightsSubSectionComponentController.OnGoToEventsSubSection += GoToEventsSubSection;
 49
 650        placesSubSectionComponentController = new PlacesSubSectionComponentController(
 51            view.PlacesSubSectionView,
 52            placesAPI,
 53            FriendsController.i,
 54            exploreV2Analytics,
 55            dataStore);
 656        placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 57
 658        eventsSubSectionComponentController = new EventsSubSectionComponentController(
 59            view.EventsSubSectionView,
 60            eventsAPI,
 61            exploreV2Analytics,
 62            dataStore);
 663        eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 64
 665        favoritesSubSectionComponentController = new FavoritesesSubSectionComponentController(
 66            view.FavoritesSubSectionView,
 67            placesAPI,
 68            FriendsController.i,
 69            exploreV2Analytics,
 70            dataStore);
 671        favoritesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 72
 673        placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged;
 674        PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false);
 675    }
 76
 277    internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); }
 78
 279    internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN
 80
 81    public void Dispose()
 82    {
 683        highlightsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 684        highlightsSubSectionComponentController.OnGoToEventsSubSection -= GoToEventsSubSection;
 685        highlightsSubSectionComponentController.Dispose();
 86
 687        placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 688        placesSubSectionComponentController.Dispose();
 89
 690        eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 691        eventsSubSectionComponentController.Dispose();
 92
 693        favoritesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 694        favoritesSubSectionComponentController.Dispose();
 95
 696        placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged;
 697    }
 98
 899    internal void PlacesAndEventsVisibleChanged(bool current, bool _) => view.SetActive(current);
 100}