| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | |
|
| | 4 | | namespace DCL.Interface |
| | 5 | | { |
| | 6 | | // TODO: remove this class when WebInterface assmebly removes the FriendController dependency |
| | 7 | | public class WebInterfaceFriendsController : IFriendsController |
| | 8 | | { |
| | 9 | | private readonly IFriendsController friendsController; |
| | 10 | |
|
| | 11 | | public event Action OnInitialized |
| | 12 | | { |
| 2 | 13 | | add => friendsController.OnInitialized += value; |
| 3 | 14 | | remove => friendsController.OnInitialized -= value; |
| | 15 | | } |
| | 16 | |
|
| | 17 | | public event Action<string, FriendshipAction> OnUpdateFriendship |
| | 18 | | { |
| 1 | 19 | | add => friendsController.OnUpdateFriendship += value; |
| 1 | 20 | | remove => friendsController.OnUpdateFriendship -= value; |
| | 21 | | } |
| | 22 | |
|
| | 23 | | public event Action<string, FriendsController.UserStatus> OnUpdateUserStatus |
| | 24 | | { |
| 2 | 25 | | add => friendsController.OnUpdateUserStatus += value; |
| 2 | 26 | | remove => friendsController.OnUpdateUserStatus -= value; |
| | 27 | | } |
| | 28 | |
|
| | 29 | | public event Action<string> OnFriendNotFound |
| | 30 | | { |
| 1 | 31 | | add => friendsController.OnFriendNotFound += value; |
| 0 | 32 | | remove => friendsController.OnFriendNotFound -= value; |
| | 33 | | } |
| | 34 | |
|
| 1 | 35 | | public int friendCount => friendsController.friendCount; |
| 2 | 36 | | public bool isInitialized => friendsController.isInitialized; |
| 1 | 37 | | public int ReceivedRequestCount => friendsController.ReceivedRequestCount; |
| | 38 | |
|
| 0 | 39 | | public WebInterfaceFriendsController(IFriendsController friendsController) |
| | 40 | | { |
| 0 | 41 | | this.friendsController = friendsController; |
| 0 | 42 | | } |
| | 43 | |
|
| 0 | 44 | | public Dictionary<string, FriendsController.UserStatus> GetFriends() => friendsController.GetFriends(); |
| | 45 | |
|
| 0 | 46 | | public FriendsController.UserStatus GetUserStatus(string userId) => friendsController.GetUserStatus(userId); |
| | 47 | |
|
| | 48 | | public bool ContainsStatus(string friendId, FriendshipStatus status) => |
| 0 | 49 | | friendsController.ContainsStatus(friendId, status); |
| | 50 | |
|
| | 51 | | public void RequestFriendship(string friendUserId) |
| | 52 | | { |
| 0 | 53 | | friendsController.RequestFriendship(friendUserId); |
| 0 | 54 | | WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage |
| | 55 | | { |
| | 56 | | userId = friendUserId, |
| | 57 | | action = FriendshipAction.REQUESTED_TO |
| | 58 | | }); |
| 0 | 59 | | } |
| | 60 | |
|
| | 61 | | public void CancelRequest(string friendUserId) |
| | 62 | | { |
| 0 | 63 | | friendsController.CancelRequest(friendUserId); |
| 0 | 64 | | WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage |
| | 65 | | { |
| | 66 | | userId = friendUserId, |
| | 67 | | action = FriendshipAction.CANCELLED |
| | 68 | | }); |
| 0 | 69 | | } |
| | 70 | |
|
| | 71 | | public void AcceptFriendship(string friendUserId) |
| | 72 | | { |
| 0 | 73 | | friendsController.AcceptFriendship(friendUserId); |
| 0 | 74 | | WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage |
| | 75 | | { |
| | 76 | | userId = friendUserId, |
| | 77 | | action = FriendshipAction.APPROVED |
| | 78 | | }); |
| 0 | 79 | | } |
| | 80 | |
|
| | 81 | | public void RejectFriendship(string friendUserId) |
| | 82 | | { |
| 0 | 83 | | friendsController.RejectFriendship(friendUserId); |
| 0 | 84 | | WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage |
| | 85 | | { |
| | 86 | | userId = friendUserId, |
| | 87 | | action = FriendshipAction.REJECTED |
| | 88 | | }); |
| 0 | 89 | | } |
| | 90 | |
|
| 0 | 91 | | public bool IsFriend(string userId) => friendsController.IsFriend(userId); |
| | 92 | |
|
| | 93 | | public void RemoveFriend(string friendId) |
| | 94 | | { |
| 0 | 95 | | friendsController.RemoveFriend(friendId); |
| 0 | 96 | | WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage |
| | 97 | | { |
| | 98 | | userId = friendId, |
| | 99 | | action = FriendshipAction.DELETED |
| | 100 | | }); |
| 0 | 101 | | } |
| | 102 | | } |
| | 103 | | } |