| | 1 | | using DCL; |
| | 2 | | using DCL.Browser; |
| | 3 | | using ExploreV2Analytics; |
| | 4 | | using System; |
| | 5 | | using DCL.Social.Friends; |
| | 6 | | using DCLServices.PlacesAPIService; |
| | 7 | | using DCLServices.WorldsAPIService; |
| | 8 | | using MainScripts.DCL.Controllers.HotScenes; |
| | 9 | | using Environment = DCL.Environment; |
| | 10 | |
|
| | 11 | | public 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 | |
|
| | 19 | | public 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 | |
|
| 18 | 34 | | internal BaseVariable<bool> placesAndEventsVisible => dataStore.exploreV2.placesAndEventsVisible; |
| | 35 | |
|
| 6 | 36 | | 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 | | { |
| 6 | 47 | | this.view = view; |
| 6 | 48 | | this.dataStore = dataStore; |
| | 49 | |
|
| 6 | 50 | | EventsAPIController eventsAPI = new EventsAPIController(); |
| | 51 | |
|
| 6 | 52 | | placesSubSectionComponentController = new PlacesSubSectionComponentController( |
| | 53 | | view.PlacesSubSectionView, |
| | 54 | | placesAPIService, |
| | 55 | | friendsController, |
| | 56 | | exploreV2Analytics, |
| | 57 | | placesAnalytics, |
| | 58 | | dataStore, |
| | 59 | | userProfileBridge); |
| 6 | 60 | | placesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 61 | |
|
| 6 | 62 | | worldsSubSectionComponentController = new WorldsSubSectionComponentController( |
| | 63 | | view.WorldsSubSectionView, |
| | 64 | | placesAPIService, |
| | 65 | | worldsAPIService, |
| | 66 | | friendsController, |
| | 67 | | exploreV2Analytics, |
| | 68 | | placesAnalytics, |
| | 69 | | dataStore, |
| | 70 | | userProfileBridge, |
| | 71 | | new WebInterfaceBrowserBridge()); |
| 6 | 72 | | worldsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 73 | |
|
| 6 | 74 | | eventsSubSectionComponentController = new EventsSubSectionComponentController( |
| | 75 | | view.EventsSubSectionView, |
| | 76 | | eventsAPI, |
| | 77 | | exploreV2Analytics, |
| | 78 | | dataStore, |
| | 79 | | userProfileBridge, |
| | 80 | | placesAPIService, |
| | 81 | | worldsAPIService); |
| 6 | 82 | | eventsSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 83 | |
|
| 6 | 84 | | favoritesSubSectionComponentController = new FavoriteSubSectionComponentController( |
| | 85 | | view.FavoritesSubSectionView, |
| | 86 | | placesAPIService, |
| | 87 | | worldsAPIService, |
| | 88 | | userProfileBridge, |
| | 89 | | exploreV2Analytics, |
| | 90 | | placesAnalytics, |
| | 91 | | this.dataStore); |
| 6 | 92 | | favoritesSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 93 | |
|
| 6 | 94 | | searchSubSectionComponentController = new SearchSubSectionComponentController( |
| | 95 | | view.SearchSubSectionView, |
| | 96 | | view.SearchBar, |
| | 97 | | eventsAPI, |
| | 98 | | placesAPIService, |
| | 99 | | worldsAPIService, |
| | 100 | | userProfileBridge, |
| | 101 | | exploreV2Analytics, |
| | 102 | | placesAnalytics, |
| | 103 | | dataStore); |
| 6 | 104 | | searchSubSectionComponentController.OnCloseExploreV2 += RequestExploreV2Closing; |
| | 105 | |
|
| 6 | 106 | | placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged; |
| 6 | 107 | | PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false); |
| 6 | 108 | | } |
| | 109 | |
|
| 2 | 110 | | internal void RequestExploreV2Closing() { OnCloseExploreV2?.Invoke(false); } |
| | 111 | |
|
| 2 | 112 | | internal void GoToEventsSubSection() { view.GoToSubsection(PlacesAndEventsSectionComponentView.EVENTS_SUB_SECTION_IN |
| | 113 | |
|
| | 114 | | public void Dispose() |
| | 115 | | { |
| 6 | 116 | | placesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 117 | | placesSubSectionComponentController.Dispose(); |
| | 118 | |
|
| 6 | 119 | | worldsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 120 | | worldsSubSectionComponentController.Dispose(); |
| | 121 | |
|
| 6 | 122 | | eventsSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 123 | | eventsSubSectionComponentController.Dispose(); |
| | 124 | |
|
| 6 | 125 | | favoritesSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| 6 | 126 | | favoritesSubSectionComponentController.Dispose(); |
| | 127 | |
|
| 6 | 128 | | searchSubSectionComponentController.OnCloseExploreV2 -= RequestExploreV2Closing; |
| | 129 | |
|
| 6 | 130 | | placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged; |
| 6 | 131 | | } |
| | 132 | |
|
| | 133 | | internal void PlacesAndEventsVisibleChanged(bool current, bool _) |
| | 134 | | { |
| 8 | 135 | | if (current && hotScenesFetcher.Ref != null) |
| 1 | 136 | | hotScenesFetcher.Ref.SetUpdateMode(IHotScenesFetcher.UpdateMode.IMMEDIATELY_ONCE); |
| | 137 | |
|
| 8 | 138 | | view.EnableSearchBar(dataStore.featureFlags.flags.Get().IsFeatureEnabled("search_in_places")); |
| 8 | 139 | | view.SetActive(current); |
| 8 | 140 | | } |
| | 141 | | } |