< 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:90
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;
 4
 5public interface IPlacesAndEventsSectionComponentController : IDisposable
 6{
 7    /// <summary>
 8    /// It will be triggered when the section want to request to close the ExploreV2 main menu.
 9    /// </summary>
 10    event Action<bool> OnCloseExploreV2;
 11}
 12
 13public class PlacesAndEventsSectionComponentController : IPlacesAndEventsSectionComponentController
 14{
 15    internal const float MIN_TIME_TO_CHECK_API = 60f;
 16
 17    public event Action<bool> OnCloseExploreV2;
 18
 19    internal IPlacesAndEventsSectionComponentView view;
 20    internal IHighlightsSubSectionComponentController highlightsSubSectionComponentController;
 21    internal IPlacesSubSectionComponentController placesSubSectionComponentController;
 22    internal IEventsSubSectionComponentController eventsSubSectionComponentController;
 23    private DataStore dataStore;
 24
 1825    internal BaseVariable<bool> placesAndEventsVisible => dataStore.exploreV2.placesAndEventsVisible;
 26
 627    public PlacesAndEventsSectionComponentController(
 28        IPlacesAndEventsSectionComponentView view,
 29        IExploreV2Analytics exploreV2Analytics,
 30        DataStore dataStore)
 31    {
 632        this.view = view;
 633        this.dataStore = dataStore;
 34
 635        PlacesAPIController placesAPI = new PlacesAPIController();
 636        EventsAPIController eventsAPI = new EventsAPIController();
 37
 638        highlightsSubSectionComponentController = new HighlightsSubSectionComponentController(
 39            view.HighlightsSubSectionView,
 40            placesAPI,
 41            eventsAPI,
 42            FriendsController.i,
 43            exploreV2Analytics,
 44            dataStore);
 45
 646        highlightsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 647        highlightsSubSectionComponentController.OnGoToEventsSubSection += GoToEventsSubSection;
 48
 649        placesSubSectionComponentController = new PlacesSubSectionComponentController(
 50            view.PlacesSubSectionView,
 51            placesAPI,
 52            FriendsController.i,
 53            exploreV2Analytics,
 54            dataStore);
 55
 656        placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 57
 658        eventsSubSectionComponentController = new EventsSubSectionComponentController(
 59            view.EventsSubSectionView,
 60            eventsAPI,
 61            exploreV2Analytics,
 62            dataStore);
 63
 664        eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 65
 666        placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged;
 667        PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false);
 668    }
 69
 270    internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); }
 71
 272    internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN
 73
 74    public void Dispose()
 75    {
 676        highlightsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 677        highlightsSubSectionComponentController.OnGoToEventsSubSection -= GoToEventsSubSection;
 678        highlightsSubSectionComponentController.Dispose();
 79
 680        placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 681        placesSubSectionComponentController.Dispose();
 82
 683        eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 684        eventsSubSectionComponentController.Dispose();
 85
 686        placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged;
 687    }
 88
 889    internal void PlacesAndEventsVisibleChanged(bool current, bool _) => view.SetActive(current);
 90}