< 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:28
Uncovered lines:0
Coverable lines:28
Total lines:91
Line coverage:100% (28 of 28)
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    private DataStore dataStore;
 25
 1826    internal BaseVariable<bool> placesAndEventsVisible => dataStore.exploreV2.placesAndEventsVisible;
 27
 628    public PlacesAndEventsSectionComponentController(
 29        IPlacesAndEventsSectionComponentView view,
 30        IExploreV2Analytics exploreV2Analytics,
 31        DataStore dataStore)
 32    {
 633        this.view = view;
 634        this.dataStore = dataStore;
 35
 636        PlacesAPIController placesAPI = new PlacesAPIController();
 637        EventsAPIController eventsAPI = new EventsAPIController();
 38
 639        highlightsSubSectionComponentController = new HighlightsSubSectionComponentController(
 40            view.HighlightsSubSectionView,
 41            placesAPI,
 42            eventsAPI,
 43            FriendsController.i,
 44            exploreV2Analytics,
 45            dataStore);
 46
 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);
 56
 657        placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 58
 659        eventsSubSectionComponentController = new EventsSubSectionComponentController(
 60            view.EventsSubSectionView,
 61            eventsAPI,
 62            exploreV2Analytics,
 63            dataStore);
 64
 665        eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 66
 667        placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged;
 668        PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false);
 669    }
 70
 271    internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); }
 72
 273    internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN
 74
 75    public void Dispose()
 76    {
 677        highlightsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 678        highlightsSubSectionComponentController.OnGoToEventsSubSection -= GoToEventsSubSection;
 679        highlightsSubSectionComponentController.Dispose();
 80
 681        placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 682        placesSubSectionComponentController.Dispose();
 83
 684        eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 685        eventsSubSectionComponentController.Dispose();
 86
 687        placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged;
 688    }
 89
 890    internal void PlacesAndEventsVisibleChanged(bool current, bool _) => view.SetActive(current);
 91}