< 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:41
Coverable lines:41
Total lines:116
Line coverage:0% (0 of 41)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
WebInterfaceFriendsApiBridgeProxy(...)0%2100%
RejectFriendship(...)0%2100%
RejectFriendshipAsync(...)0%2100%
RemoveFriend(...)0%2100%
GetFriendsAsync(...)0%2100%
GetFriendsAsync(...)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%
AcceptFriendshipAsync(...)0%2100%
GetFriendshipStatus(...)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;
 4using System.Threading;
 5
 6namespace DCL.Social.Friends
 7{
 8    // TODO (NEW FRIEND REQUESTS): remove when we don't need to keep the retro-compatibility with the old version
 9    public class WebInterfaceFriendsApiBridgeProxy : IFriendsApiBridge
 10    {
 11        private const string NEW_FRIEND_REQUESTS_FLAG = "new_friend_requests";
 12
 13        private readonly IFriendsApiBridge fallbackApiBridge;
 14        private readonly IFriendsApiBridge newFriendsApiBridge;
 15        private readonly DataStore dataStore;
 16
 017        private bool isNewFriendRequestsEnabled => dataStore.featureFlags.flags.Get().IsFeatureEnabled(NEW_FRIEND_REQUES
 018        private IFriendsApiBridge apiBridgeInUse => isNewFriendRequestsEnabled ? newFriendsApiBridge : fallbackApiBridge
 19
 20        public event Action<FriendshipInitializationMessage> OnInitialized;
 21        public event Action<string> OnFriendNotFound;
 22        public event Action<AddFriendsPayload> OnFriendsAdded;
 23        public event Action<AddFriendsWithDirectMessagesPayload> OnFriendWithDirectMessagesAdded;
 24        public event Action<UserStatus> OnUserPresenceUpdated;
 25        public event Action<FriendshipUpdateStatusMessage> OnFriendshipStatusUpdated;
 26        public event Action<UpdateTotalFriendRequestsPayload> OnTotalFriendRequestCountUpdated;
 27        public event Action<UpdateTotalFriendsPayload> OnTotalFriendCountUpdated;
 28        public event Action<FriendRequestPayload> OnFriendRequestReceived;
 29        public event Action<AddFriendRequestsPayload> OnFriendRequestsAdded;
 30
 031        public WebInterfaceFriendsApiBridgeProxy(IFriendsApiBridge fallbackApiBridge, IFriendsApiBridge newFriendsApiBri
 32        {
 033            this.fallbackApiBridge = fallbackApiBridge;
 034            this.newFriendsApiBridge = newFriendsApiBridge;
 035            this.dataStore = dataStore;
 36
 037            this.fallbackApiBridge.OnInitialized += x => OnInitialized?.Invoke(x);
 038            this.newFriendsApiBridge.OnInitialized += x => OnInitialized?.Invoke(x);
 39
 040            this.fallbackApiBridge.OnFriendNotFound += x => OnFriendNotFound?.Invoke(x);
 041            this.newFriendsApiBridge.OnFriendNotFound += x => OnFriendNotFound?.Invoke(x);
 42
 043            this.fallbackApiBridge.OnFriendWithDirectMessagesAdded += x => OnFriendWithDirectMessagesAdded?.Invoke(x);
 044            this.newFriendsApiBridge.OnFriendWithDirectMessagesAdded += x => OnFriendWithDirectMessagesAdded?.Invoke(x);
 45
 046            this.fallbackApiBridge.OnUserPresenceUpdated += x => OnUserPresenceUpdated?.Invoke(x);
 047            this.newFriendsApiBridge.OnUserPresenceUpdated += x => OnUserPresenceUpdated?.Invoke(x);
 48
 049            this.fallbackApiBridge.OnFriendshipStatusUpdated += x => OnFriendshipStatusUpdated?.Invoke(x);
 050            this.newFriendsApiBridge.OnFriendshipStatusUpdated += x => OnFriendshipStatusUpdated?.Invoke(x);
 51
 052            this.fallbackApiBridge.OnTotalFriendRequestCountUpdated += x => OnTotalFriendRequestCountUpdated?.Invoke(x);
 053            this.newFriendsApiBridge.OnTotalFriendRequestCountUpdated += x => OnTotalFriendRequestCountUpdated?.Invoke(x
 54
 055            this.fallbackApiBridge.OnTotalFriendCountUpdated += x => OnTotalFriendCountUpdated?.Invoke(x);
 056            this.newFriendsApiBridge.OnTotalFriendCountUpdated += x => OnTotalFriendCountUpdated?.Invoke(x);
 57
 058            this.fallbackApiBridge.OnFriendRequestsAdded += x => OnFriendRequestsAdded?.Invoke(x);
 059            this.newFriendsApiBridge.OnFriendRequestsAdded += x => OnFriendRequestsAdded?.Invoke(x);
 60
 061            this.fallbackApiBridge.OnFriendRequestReceived += x => OnFriendRequestReceived?.Invoke(x);
 062            this.newFriendsApiBridge.OnFriendRequestReceived += x => OnFriendRequestReceived?.Invoke(x);
 063        }
 64
 65        public void RejectFriendship(string userId) =>
 066            apiBridgeInUse.RejectFriendship(userId);
 67
 68        public UniTask<RejectFriendshipPayload> RejectFriendshipAsync(string friendRequestId, CancellationToken cancella
 069            apiBridgeInUse.RejectFriendshipAsync(friendRequestId, cancellationToken);
 70
 71        public void RemoveFriend(string userId) =>
 072            apiBridgeInUse.RemoveFriend(userId);
 73
 74        public UniTask<AddFriendsPayload> GetFriendsAsync(int limit, int skip, CancellationToken cancellationToken = def
 075            apiBridgeInUse.GetFriendsAsync(limit, skip, cancellationToken);
 76
 77        public UniTask<AddFriendsPayload> GetFriendsAsync(string usernameOrId, int limit, CancellationToken cancellation
 078            apiBridgeInUse.GetFriendsAsync(usernameOrId, limit, cancellationToken);
 79
 80        public void GetFriendRequests(int sentLimit, int sentSkip, int receivedLimit, int receivedSkip) =>
 081            apiBridgeInUse.GetFriendRequests(sentLimit, sentSkip, receivedLimit, receivedSkip);
 82
 83        public UniTask<AddFriendRequestsV2Payload> GetFriendRequestsAsync(int sentLimit, int sentSkip,
 84            int receivedLimit, int receivedSkip,
 85            CancellationToken cancellationToken) =>
 086            apiBridgeInUse.GetFriendRequestsAsync(sentLimit, sentSkip, receivedLimit, receivedSkip, cancellationToken);
 87
 88        public void GetFriendsWithDirectMessages(string usernameOrId, int limit, int skip) =>
 089            apiBridgeInUse.GetFriendsWithDirectMessages(usernameOrId, limit, skip);
 90
 91        public void RequestFriendship(string friendUserId) =>
 092            apiBridgeInUse.RequestFriendship(friendUserId);
 93
 94        public UniTask<RequestFriendshipConfirmationPayload> RequestFriendshipAsync(string userId, string messageBody,
 95            CancellationToken cancellationToken) =>
 096            apiBridgeInUse.RequestFriendshipAsync(userId, messageBody, cancellationToken);
 97
 98        public UniTask<CancelFriendshipConfirmationPayload> CancelRequestAsync(string userId, CancellationToken cancella
 099            apiBridgeInUse.CancelRequestAsync(userId, cancellationToken);
 100
 101        public UniTask CancelRequestByUserIdAsync(string userId, CancellationToken cancellationToken) =>
 0102            apiBridgeInUse.CancelRequestByUserIdAsync(userId, cancellationToken);
 103
 104        public void CancelRequestByUserId(string userId) =>
 0105            apiBridgeInUse.CancelRequestByUserId(userId);
 106
 107        public void AcceptFriendship(string userId) =>
 0108            apiBridgeInUse.AcceptFriendship(userId);
 109
 110        public UniTask<AcceptFriendshipPayload> AcceptFriendshipAsync(string friendRequestId, CancellationToken cancella
 0111            apiBridgeInUse.AcceptFriendshipAsync(friendRequestId, cancellationToken);
 112
 113        public UniTask<FriendshipStatus> GetFriendshipStatus(string userId, CancellationToken cancellationToken) =>
 0114            newFriendsApiBridge.GetFriendshipStatus(userId, cancellationToken);
 115    }
 116}