< Summary

Class:DCLPlugins.CameraReelPlugin.CameraReelPlugin
Assembly:CameraReelPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/CameraReelPlugin/CameraReelPlugin.cs
Covered lines:0
Uncovered lines:39
Coverable lines:39
Total lines:119
Line coverage:0% (0 of 39)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:6
Method coverage:0% (0 of 6)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CameraReelPlugin()0%2100%
Initialize()0%56700%
Dispose()0%12300%
OnThumbnailContextMenuAdded(...)0%2100%
CreateCameraReelSectionView()0%12300%
OnVisiblePersonAdded(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/CameraReelPlugin/CameraReelPlugin.cs

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using DCL;
 3using DCL.Browser;
 4using DCL.Providers;
 5using DCLFeatures.CameraReel.Gallery;
 6using DCLFeatures.CameraReel.ScreenshotViewer;
 7using DCLFeatures.CameraReel.Section;
 8using DCLServices.CameraReelService;
 9using DCLServices.EnvironmentProvider;
 10using DCLServices.WearablesCatalogService;
 11using System.Collections.Generic;
 12using UnityEngine;
 13
 14namespace DCLPlugins.CameraReelPlugin
 15{
 16    public class CameraReelPlugin : IPlugin
 17    {
 18        private const string ADDRESS = "CameraReelSectionView";
 19
 020        private readonly List<ThumbnailContextMenuController> thumbnailContextMenuControllers = new ();
 021        private readonly List<ScreenshotVisiblePersonController> visiblePersonControllers = new ();
 22
 23        private Transform sectionParent;
 24        private CameraReelSectionController reelSectionController;
 25        private CameraReelModel cameraReelModel;
 26
 27        private ICameraReelStorageService storageService;
 28
 029        public CameraReelPlugin()
 30        {
 031            Initialize().Forget();
 032        }
 33
 34        private async UniTaskVoid Initialize()
 35        {
 036            await UniTask.WaitUntil(() => DataStore.i.player.ownPlayer.Get() != null && !string.IsNullOrEmpty(DataStore.
 37
 038            if (UserProfileController.userProfilesCatalog.Get(DataStore.i.player.ownPlayer.Get().id).isGuest)
 039                return;
 40
 041            IAddressableResourceProvider assetProvider = Environment.i.platform.serviceLocator.Get<IAddressableResourceP
 42
 043            CameraReelSectionView view = await CreateCameraReelSectionView(assetProvider);
 044            storageService = Environment.i.serviceLocator.Get<ICameraReelStorageService>();
 045            DataStore dataStore = DataStore.i;
 046            cameraReelModel = new CameraReelModel();
 047            ICameraReelAnalyticsService analytics = Environment.i.serviceLocator.Get<ICameraReelAnalyticsService>();
 48
 049            reelSectionController = new CameraReelSectionController(view, view.GalleryView, view.GalleryStorageView,
 50                dataStore,
 51                storageService,
 52                cameraReelModel,
 53                () =>
 54                {
 055                    ScreenshotViewerView screenshotViewerView = Object.Instantiate(view.ScreenshotViewerPrefab);
 56
 057                    return new ScreenshotViewerController(screenshotViewerView, cameraReelModel, dataStore,
 58                        storageService, new UserProfileWebInterfaceBridge(),
 59                        Clipboard.Create(), new WebInterfaceBrowserBridge(),
 60                        analytics, Environment.i.serviceLocator.Get<IEnvironmentProviderService>(),
 61                        screenshotViewerView.ActionPanel,
 62                        screenshotViewerView.InfoSidePanel);
 63                }, analytics);
 64
 065            ThumbnailContextMenuView.Instances.OnAdded += OnThumbnailContextMenuAdded;
 066            ScreenshotVisiblePersonView.Instances.OnAdded += OnVisiblePersonAdded;
 67
 068            storageService.ScreenshotUploaded += cameraReelModel.AddScreenshotAsFirst;
 69
 070            dataStore.HUDs.isCameraReelInitialized.Set(true);
 071        }
 72
 73        public void Dispose()
 74        {
 075            ThumbnailContextMenuView.Instances.OnAdded -= OnThumbnailContextMenuAdded;
 076            ScreenshotVisiblePersonView.Instances.OnAdded -= OnVisiblePersonAdded;
 77
 078            storageService.ScreenshotUploaded -= cameraReelModel.AddScreenshotAsFirst;
 79
 080            foreach (ThumbnailContextMenuController controller in thumbnailContextMenuControllers)
 081                controller.Dispose();
 82
 083            thumbnailContextMenuControllers.Clear();
 84
 085            foreach (ScreenshotVisiblePersonController controller in visiblePersonControllers)
 086                controller.Dispose();
 87
 088            visiblePersonControllers.Clear();
 89
 090            reelSectionController.Dispose();
 091        }
 92
 93        private void OnThumbnailContextMenuAdded(ThumbnailContextMenuView view)
 94        {
 095            ThumbnailContextMenuController controller = new (view, Clipboard.Create(), cameraReelModel,
 96                new WebInterfaceBrowserBridge(),
 97                Environment.i.serviceLocator.Get<ICameraReelStorageService>(),
 98                DataStore.i,
 99                Environment.i.serviceLocator.Get<ICameraReelAnalyticsService>(),
 100                Environment.i.serviceLocator.Get<IEnvironmentProviderService>());
 101
 0102            thumbnailContextMenuControllers.Add(controller);
 0103        }
 104
 105        private static async UniTask<CameraReelSectionView> CreateCameraReelSectionView(IAddressableResourceProvider ass
 0106            await assetProvider.Instantiate<CameraReelSectionView>(ADDRESS, ADDRESS,
 107                parent: DataStore.i.exploreV2.configureCameraReelInFullScreenMenu.Get());
 108
 109        private void OnVisiblePersonAdded(ScreenshotVisiblePersonView view)
 110        {
 0111            visiblePersonControllers.Add(new ScreenshotVisiblePersonController(view,
 112                Environment.i.serviceLocator.Get<IWearablesCatalogService>(),
 113                new UserProfileWebInterfaceBridge(),
 114                new WebInterfaceBrowserBridge(),
 115                DataStore.i,
 116                Environment.i.serviceLocator.Get<ICameraReelAnalyticsService>()));
 0117        }
 118    }
 119}