< Summary

Class:DCL.Social.Friends.WebInterfaceFriendsApiBridgeProxy
Assembly:FriendsController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/FriendsController/WebInterfaceFriendsApiBridgeProxy.cs
Covered lines:0
Uncovered lines:40
Coverable lines:40
Total lines:106
Line coverage:0% (0 of 40)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
WebInterfaceFriendsApiBridgeProxy(...)0%2100%
RejectFriendship(...)0%2100%
RemoveFriend(...)0%2100%
GetFriends(...)0%2100%
GetFriends(...)0%2100%
GetFriendRequests(...)0%2100%
GetFriendRequestsAsync(...)0%2100%
GetFriendsWithDirectMessages(...)0%2100%
RequestFriendship(...)0%2100%
RequestFriendshipAsync(...)0%2100%
CancelRequestAsync(...)0%2100%
CancelRequestByUserIdAsync(...)0%2100%
CancelRequestByUserId(...)0%2100%
AcceptFriendship(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/FriendsController/WebInterfaceFriendsApiBridgeProxy.cs

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using DCl.Social.Friends;
 3using System;
 4
 5namespace DCL.Social.Friends
 6{
 7    // TODO (NEW FRIEND REQUESTS): remove when we don't need to keep the retro-compatibility with the old version
 8    public class WebInterfaceFriendsApiBridgeProxy : IFriendsApiBridge
 9    {
 10        private const string NEW_FRIEND_REQUESTS_FLAG = "new_friend_requests";
 11
 12        private readonly IFriendsApiBridge apiBridge;
 13        private readonly IFriendsApiBridge apiBridgeMock;
 14        private readonly DataStore dataStore;
 15
 016        private bool isNewFriendRequestsEnabled => dataStore.featureFlags.flags.Get().IsFeatureEnabled(NEW_FRIEND_REQUES
 017        private IFriendsApiBridge apiBridgeInUse => isNewFriendRequestsEnabled ? apiBridgeMock : apiBridge;
 18
 19        public event Action<FriendshipInitializationMessage> OnInitialized;
 20        public event Action<string> OnFriendNotFound;
 21        public event Action<AddFriendsPayload> OnFriendsAdded;
 22        public event Action<AddFriendsWithDirectMessagesPayload> OnFriendWithDirectMessagesAdded;
 23        public event Action<UserStatus> OnUserPresenceUpdated;
 24        public event Action<FriendshipUpdateStatusMessage> OnFriendshipStatusUpdated;
 25        public event Action<UpdateTotalFriendRequestsPayload> OnTotalFriendRequestCountUpdated;
 26        public event Action<UpdateTotalFriendsPayload> OnTotalFriendCountUpdated;
 27        public event Action<FriendRequestPayload> OnFriendRequestAdded;
 28        public event Action<AddFriendRequestsPayload> OnFriendRequestsAdded;
 29
 030        public WebInterfaceFriendsApiBridgeProxy(IFriendsApiBridge apiBridge, IFriendsApiBridge apiBridgeMock, DataStore
 31        {
 032            this.apiBridge = apiBridge;
 033            this.apiBridgeMock = apiBridgeMock;
 034            this.dataStore = dataStore;
 35
 036            this.apiBridge.OnInitialized += x => OnInitialized?.Invoke(x);
 037            this.apiBridgeMock.OnInitialized += x => OnInitialized?.Invoke(x);
 38
 039            this.apiBridge.OnFriendNotFound += x => OnFriendNotFound?.Invoke(x);
 040            this.apiBridgeMock.OnFriendNotFound += x => OnFriendNotFound?.Invoke(x);
 41
 042            this.apiBridge.OnFriendsAdded += x => OnFriendsAdded?.Invoke(x);
 043            this.apiBridgeMock.OnFriendsAdded += x => OnFriendsAdded?.Invoke(x);
 44
 045            this.apiBridge.OnFriendWithDirectMessagesAdded += x => OnFriendWithDirectMessagesAdded?.Invoke(x);
 046            this.apiBridgeMock.OnFriendWithDirectMessagesAdded += x => OnFriendWithDirectMessagesAdded?.Invoke(x);
 47
 048            this.apiBridge.OnUserPresenceUpdated += x => OnUserPresenceUpdated?.Invoke(x);
 049            this.apiBridgeMock.OnUserPresenceUpdated += x => OnUserPresenceUpdated?.Invoke(x);
 50
 051            this.apiBridge.OnFriendshipStatusUpdated += x => OnFriendshipStatusUpdated?.Invoke(x);
 052            this.apiBridgeMock.OnFriendshipStatusUpdated += x => OnFriendshipStatusUpdated?.Invoke(x);
 53
 054            this.apiBridge.OnTotalFriendRequestCountUpdated += x => OnTotalFriendRequestCountUpdated?.Invoke(x);
 055            this.apiBridgeMock.OnTotalFriendRequestCountUpdated += x => OnTotalFriendRequestCountUpdated?.Invoke(x);
 56
 057            this.apiBridge.OnTotalFriendCountUpdated += x => OnTotalFriendCountUpdated?.Invoke(x);
 058            this.apiBridgeMock.OnTotalFriendCountUpdated += x => OnTotalFriendCountUpdated?.Invoke(x);
 59
 060            this.apiBridge.OnFriendRequestAdded += x => OnFriendRequestAdded?.Invoke(x);
 061            this.apiBridgeMock.OnFriendRequestAdded += x => OnFriendRequestAdded?.Invoke(x);
 62
 063            this.apiBridge.OnFriendRequestsAdded += x => OnFriendRequestsAdded?.Invoke(x);
 064            this.apiBridgeMock.OnFriendRequestsAdded += x => OnFriendRequestsAdded?.Invoke(x);
 065        }
 66
 67        public void RejectFriendship(string userId) =>
 068            apiBridgeInUse.RejectFriendship(userId);
 69
 70        public void RemoveFriend(string userId) =>
 071            apiBridgeInUse.RemoveFriend(userId);
 72
 73        public void GetFriends(int limit, int skip) =>
 074            apiBridgeInUse.GetFriends(limit, skip);
 75
 76        public void GetFriends(string usernameOrId, int limit) =>
 077            apiBridgeInUse.GetFriends(usernameOrId, limit);
 78
 79        public void GetFriendRequests(int sentLimit, int sentSkip, int receivedLimit, int receivedSkip) =>
 080            apiBridgeInUse.GetFriendRequests(sentLimit, sentSkip, receivedLimit, receivedSkip);
 81
 82        public UniTask<AddFriendRequestsV2Payload> GetFriendRequestsAsync(int sentLimit, int sentSkip, int receivedLimit
 083            apiBridgeInUse.GetFriendRequestsAsync(sentLimit, sentSkip, receivedLimit, receivedSkip);
 84
 85        public void GetFriendsWithDirectMessages(string usernameOrId, int limit, int skip) =>
 086            apiBridgeInUse.GetFriendsWithDirectMessages(usernameOrId, limit, skip);
 87
 88        public void RequestFriendship(string friendUserId) =>
 089            apiBridgeInUse.RequestFriendship(friendUserId);
 90
 91        public UniTask<RequestFriendshipConfirmationPayload> RequestFriendshipAsync(string userId, string messageBody) =
 092            apiBridgeInUse.RequestFriendshipAsync(userId, messageBody);
 93
 94        public UniTask<CancelFriendshipConfirmationPayload> CancelRequestAsync(string userId) =>
 095            apiBridgeInUse.CancelRequestAsync(userId);
 96
 97        public UniTask CancelRequestByUserIdAsync(string userId) =>
 098            apiBridgeInUse.CancelRequestByUserIdAsync(userId);
 99
 100        public void CancelRequestByUserId(string userId) =>
 0101            apiBridgeInUse.CancelRequestByUserId(userId);
 102
 103        public void AcceptFriendship(string userId) =>
 0104            apiBridgeInUse.AcceptFriendship(userId);
 105    }
 106}