< 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:36
Uncovered lines:0
Coverable lines:36
Total lines:141
Line coverage:100% (36 of 36)
Covered branches:0
Total branches:0
Covered methods:6
Total methods:6
Method coverage:100% (6 of 6)

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%330100%

File(s)

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

#LineLine coverage
 1using DCL;
 2using DCL.Browser;
 3using ExploreV2Analytics;
 4using System;
 5using DCL.Social.Friends;
 6using DCLServices.PlacesAPIService;
 7using DCLServices.WorldsAPIService;
 8using MainScripts.DCL.Controllers.HotScenes;
 9using Environment = DCL.Environment;
 10
 11public interface IPlacesAndEventsSectionComponentController : IDisposable
 12{
 13    /// <summary>
 14    /// It will be triggered when the section want to request to close the ExploreV2 main menu.
 15    /// </summary>
 16    event Action<bool> OnCloseExploreV2;
 17}
 18
 19public class PlacesAndEventsSectionComponentController : IPlacesAndEventsSectionComponentController
 20{
 21    internal const float MIN_TIME_TO_CHECK_API = 60f;
 22
 23    public event Action<bool> OnCloseExploreV2;
 24
 25    internal IPlacesAndEventsSectionComponentView view;
 26    internal IPlacesSubSectionComponentController placesSubSectionComponentController;
 27    internal IWorldsSubSectionComponentController worldsSubSectionComponentController;
 28    internal IEventsSubSectionComponentController eventsSubSectionComponentController;
 29    internal IFavoriteSubSectionComponentController favoritesSubSectionComponentController;
 30    internal ISearchSubSectionComponentController searchSubSectionComponentController;
 31    private DataStore dataStore;
 32    private static Service<IHotScenesFetcher> hotScenesFetcher;
 33
 1834    internal BaseVariable<bool> placesAndEventsVisible => dataStore.exploreV2.placesAndEventsVisible;
 35
 636    public PlacesAndEventsSectionComponentController(
 37        IPlacesAndEventsSectionComponentView view,
 38        IExploreV2Analytics exploreV2Analytics,
 39        DataStore dataStore,
 40        IUserProfileBridge userProfileBridge,
 41        IFriendsController friendsController,
 42        IPlacesAPIService placesAPIService,
 43        IWorldsAPIService worldsAPIService,
 44        IPlacesAnalytics placesAnalytics
 45        )
 46    {
 647        this.view = view;
 648        this.dataStore = dataStore;
 49
 650        EventsAPIController eventsAPI = new EventsAPIController();
 51
 652        placesSubSectionComponentController = new PlacesSubSectionComponentController(
 53            view.PlacesSubSectionView,
 54            placesAPIService,
 55            friendsController,
 56            exploreV2Analytics,
 57            placesAnalytics,
 58            dataStore,
 59            userProfileBridge);
 660        placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 61
 662        worldsSubSectionComponentController = new WorldsSubSectionComponentController(
 63            view.WorldsSubSectionView,
 64            placesAPIService,
 65            worldsAPIService,
 66            friendsController,
 67            exploreV2Analytics,
 68            placesAnalytics,
 69            dataStore,
 70            userProfileBridge,
 71            new WebInterfaceBrowserBridge());
 672        worldsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 73
 674        eventsSubSectionComponentController = new EventsSubSectionComponentController(
 75            view.EventsSubSectionView,
 76            eventsAPI,
 77            exploreV2Analytics,
 78            dataStore,
 79            userProfileBridge,
 80            placesAPIService,
 81            worldsAPIService);
 682        eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 83
 684        favoritesSubSectionComponentController = new FavoriteSubSectionComponentController(
 85            view.FavoritesSubSectionView,
 86            placesAPIService,
 87            worldsAPIService,
 88            userProfileBridge,
 89            exploreV2Analytics,
 90            placesAnalytics,
 91            this.dataStore);
 692        favoritesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 93
 694        searchSubSectionComponentController = new SearchSubSectionComponentController(
 95            view.SearchSubSectionView,
 96            view.SearchBar,
 97            eventsAPI,
 98            placesAPIService,
 99            worldsAPIService,
 100            userProfileBridge,
 101            exploreV2Analytics,
 102            placesAnalytics,
 103            dataStore);
 6104        searchSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing;
 105
 6106        placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged;
 6107        PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false);
 6108    }
 109
 2110    internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); }
 111
 2112    internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN
 113
 114    public void Dispose()
 115    {
 6116        placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 6117        placesSubSectionComponentController.Dispose();
 118
 6119        worldsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 6120        worldsSubSectionComponentController.Dispose();
 121
 6122        eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 6123        eventsSubSectionComponentController.Dispose();
 124
 6125        favoritesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 6126        favoritesSubSectionComponentController.Dispose();
 127
 6128        searchSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing;
 129
 6130        placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged;
 6131    }
 132
 133    internal void PlacesAndEventsVisibleChanged(bool current, bool _)
 134    {
 8135        if (current && hotScenesFetcher.Ref != null)
 1136            hotScenesFetcher.Ref.SetUpdateMode(IHotScenesFetcher.UpdateMode.IMMEDIATELY_ONCE);
 137
 8138        view.EnableSearchBar(dataStore.featureFlags.flags.Get().IsFeatureEnabled("search_in_places"));
 8139        view.SetActive(current);
 8140    }
 141}