Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Explorer/Assets/DCL/Chat/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using DCL.Multiplayer.Profiles.Tables;
using DCL.Nametags;
using DCL.Profiles;
using DCL.UI.Profiles.Helpers;
using DCL.RealmNavigation;
using DCL.Settings.Settings;
using DCL.UI;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class ChatController : ControllerBase<ChatView, ChatControllerShowParams>
private readonly ChatControllerChatBubblesHelper chatBubblesHelper;
private readonly ChatControllerMemberListHelper memberListHelper;
private readonly IRoomHub roomHub;
private readonly ProfileRepositoryWrapper profileRepositoryWrapper;

private readonly List<ChatMemberListView.MemberData> membersBuffer = new ();
private readonly List<Profile> participantProfileBuffer = new ();
Expand Down Expand Up @@ -107,7 +109,8 @@ public ChatController(
RPCChatPrivacyService chatPrivacyService,
IFriendsEventBus friendsEventBus,
ChatHistoryStorage chatStorage,
ObjectProxy<IFriendsService> friendsService) : base(viewFactory)
ObjectProxy<IFriendsService> friendsService,
ProfileRepositoryWrapper profileDataProvider) : base(viewFactory)
{
this.chatMessagesBus = chatMessagesBus;
this.chatHistory = chatHistory;
Expand All @@ -124,6 +127,7 @@ public ChatController(
this.web3IdentityCache = web3IdentityCache;
this.loadingStatus = loadingStatus;
this.chatStorage = chatStorage;
this.profileRepositoryWrapper = profileDataProvider;

chatUserStateEventBus = new ChatUserStateEventBus();
var chatRoom = roomHub.ChatRoom();
Expand Down Expand Up @@ -231,6 +235,7 @@ protected override void OnViewShow()
cameraEntity = world.CacheCamera();

viewInstance!.InjectDependencies(viewDependencies);
viewInstance.SetProfileDataPovider(profileRepositoryWrapper);
viewInstance.Initialize(chatHistory.Channels, chatSettings, GetProfilesFromParticipants, loadingStatus);
chatStorage?.SetNewLocalUserWalletAddress(web3IdentityCache.Identity!.Address);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using DCL.Multiplayer.Profiles.Tables;
using DCL.Settings.Settings;
using Utility.Arch;
using DCL.UI.Profiles.Helpers;
using DCL.Profiles.Helpers;

namespace DCL.Chat
{
Expand Down
19 changes: 11 additions & 8 deletions Explorer/Assets/DCL/Chat/ChatConversationsToolbarView.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Cysharp.Threading.Tasks;
using DCL.Chat.History;
using DCL.Profiles;
using DCL.UI.Profiles.Helpers;
using DCL.UI;
using DG.Tweening;
using MVC;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
Expand All @@ -13,7 +13,7 @@

namespace DCL.Chat
{
public class ChatConversationsToolbarView : MonoBehaviour, IViewWithGlobalDependencies, IPointerEnterHandler, IPointerExitHandler
public class ChatConversationsToolbarView : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public delegate void ConversationSelectedDelegate(ChatChannel.ChannelId channelId);
public delegate void ConversationRemovalRequestedDelegate(ChatChannel.ChannelId channelId);
Expand All @@ -36,9 +36,8 @@ public class ChatConversationsToolbarView : MonoBehaviour, IViewWithGlobalDepend
[SerializeField]
private Button scrollDownButton;

private ViewDependencies viewDependencies;

private Dictionary<ChatChannel.ChannelId, ChatConversationsToolbarViewItem> items = new ();
private ProfileRepositoryWrapper profileRepositoryWrapper;

/// <summary>
/// Raised when a different conversation item is selected.
Expand Down Expand Up @@ -152,9 +151,13 @@ public void SetConnectionStatus(ChatChannel.ChannelId destinationChannel, Online
items[destinationChannel].SetConnectionStatus(connectionStatus);
}

public void InjectDependencies(ViewDependencies dependencies)
/// <summary>
///
/// </summary>
/// <param name="profileRepositoryWrapper"></param>
public void SetProfileDataProvider(ProfileRepositoryWrapper profileDataProvider)
{
viewDependencies = dependencies;
this.profileRepositoryWrapper = profileDataProvider;
}

/// <summary>
Expand Down Expand Up @@ -261,11 +264,11 @@ private void OnItemTooltipShown(GameObject tooltip)

private async UniTaskVoid SetupUserConversationItemAsync(ChatConversationsToolbarViewItem newItem)
{
Profile? profile = await viewDependencies.GetProfileAsync(newItem.Id.Id, CancellationToken.None);
Profile? profile = await profileRepositoryWrapper.GetProfileAsync(newItem.Id.Id, CancellationToken.None);

if (profile != null)
{
newItem.SetProfileData(viewDependencies, profile.UserNameColor, profile.Avatar.FaceSnapshotUrl, profile.UserId);
newItem.SetProfileData(profileRepositoryWrapper, profile.UserNameColor, profile.Avatar.FaceSnapshotUrl, profile.UserId);
newItem.SetConversationName(profile.ValidatedName);
newItem.SetClaimedNameIconVisibility(profile.HasClaimedName);
newItem.SetConversationType(true);
Expand Down
8 changes: 4 additions & 4 deletions Explorer/Assets/DCL/Chat/ChatConversationsToolbarViewItem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using DCL.Chat.History;
using DCL.UI.Profiles.Helpers;
using DCL.UI;
using DCL.UI.Buttons;
using DCL.UI.ProfileElements;
using DG.Tweening;
using MVC;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
Expand Down Expand Up @@ -146,15 +146,15 @@ public void SetSelectionStatus(bool isSelected)
/// <summary>
/// Provides the data required to display the profile picture.
/// </summary>
/// <param name="viewDependencies">A set of system tools for views.</param>
/// <param name="profileDataProvider">A way to access Profile data asynchronously.</param>
/// <param name="userColor">The color of the user's profile picture. It affects the tooltip too.</param>
/// <param name="faceSnapshotUrl">The URL to the profile picture.</param>
/// <param name="userId">The Id of the user (wallet Id).</param>
public void SetProfileData(ViewDependencies viewDependencies, Color userColor, string faceSnapshotUrl, string userId)
public void SetProfileData(ProfileRepositoryWrapper profileDataProvider, Color userColor, string faceSnapshotUrl, string userId)
{
customIcon.gameObject.SetActive(false);
profilePictureView.gameObject.SetActive(true);
profilePictureView.SetupWithDependencies(viewDependencies, userColor, faceSnapshotUrl, userId);
profilePictureView.SetupWithDependencies(profileDataProvider, userColor, faceSnapshotUrl, userId);
tooltipText.color = userColor;
}

Expand Down
12 changes: 10 additions & 2 deletions Explorer/Assets/DCL/Chat/ChatInputBoxElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using DCL.Audio;
using DCL.Emoji;
using DCL.Profiles;
using DCL.UI.Profiles.Helpers;
using DCL.Settings.Settings;
using DCL.UI;
using DCL.UI.CustomInputField;
Expand Down Expand Up @@ -81,6 +82,8 @@ public class ChatInputBoxElement : MonoBehaviour, IViewWithGlobalDependencies

private bool isInputSubmissionEnabled;

private ProfileRepositoryWrapper profileRepositoryWrapper;

public string InputBoxText
{
get => inputField.text;
Expand All @@ -107,6 +110,11 @@ public void InjectDependencies(ViewDependencies dependencies)
viewDependencies = dependencies;
}

public void SetProfileDataProvider(ProfileRepositoryWrapper profileDataProvider)
{
profileRepositoryWrapper = profileDataProvider;
}

private bool IsEmojisEnabled
{
get => emojiPanelButton.gameObject.activeSelf;
Expand Down Expand Up @@ -480,11 +488,11 @@ private void UpdateProfileNameMap()
if (profileSuggestionsDictionary.TryGetValue(profile.DisplayName, out ProfileInputSuggestionData profileSuggestionData))
{
if (profileSuggestionData.ProfileData != profile)
profileSuggestionsDictionary[profile.DisplayName] = new ProfileInputSuggestionData(profile, viewDependencies);
profileSuggestionsDictionary[profile.DisplayName] = new ProfileInputSuggestionData(profile, profileRepositoryWrapper);
}
else
{
profileSuggestionsDictionary.TryAdd(profile.DisplayName, new ProfileInputSuggestionData(profile, viewDependencies));
profileSuggestionsDictionary.TryAdd(profile.DisplayName, new ProfileInputSuggestionData(profile, profileRepositoryWrapper));
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion Explorer/Assets/DCL/Chat/ChatMemberListView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cysharp.Threading.Tasks;
using DCL.UI.Profiles.Helpers;
using DCL.UI.Utilities;
using DCL.Web3;
using MVC;
Expand Down Expand Up @@ -40,6 +41,7 @@ public struct MemberData
private List<MemberData> members = new ();

private ViewDependencies viewDependencies;
private ProfileRepositoryWrapper profileRepositoryWrapper;
private bool isInitialized;
private bool isVisible;
private UniTaskCompletionSource contextMenuTask = new ();
Expand Down Expand Up @@ -75,6 +77,11 @@ public void InjectDependencies(ViewDependencies dependencies)
viewDependencies = dependencies;
}

public void SetProfileDataProvider(ProfileRepositoryWrapper profileDataProvider)
{
profileRepositoryWrapper = profileDataProvider;
}

/// <summary>
/// Replaces the data to be represented by the view.
/// </summary>
Expand Down Expand Up @@ -102,7 +109,7 @@ private LoopListViewItem2 OnGetItemByIndex(LoopListView2 list, int index)
ChatMemberListViewItem memberItem = newItem.GetComponent<ChatMemberListViewItem>();
memberItem.Id = members[index].Id;
memberItem.Name = members[index].Name;
memberItem.SetupProfilePicture(viewDependencies, members[index].ProfileColor, members[index].FaceSnapshotUrl, members[index].Id);
memberItem.SetupProfilePicture(profileRepositoryWrapper, members[index].ProfileColor, members[index].FaceSnapshotUrl, members[index].Id);
memberItem.ConnectionStatus = members[index].ConnectionStatus;
memberItem.Tag = members[index].WalletId;
memberItem.NameTextColor = members[index].ProfileColor;
Expand Down
6 changes: 3 additions & 3 deletions Explorer/Assets/DCL/Chat/ChatMemberListViewItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using DCL.UI.Profiles.Helpers;
using DCL.UI.ProfileElements;
using MVC;
using System;
using TMPro;
using UnityEngine;
Expand Down Expand Up @@ -69,9 +69,9 @@ public void OnPointerExit(PointerEventData eventData)
contextMenuButton.gameObject.SetActive(false);
}

public void SetupProfilePicture(ViewDependencies viewDependencies, Color userColor, string faceSnapshotUrl, string userId)
public void SetupProfilePicture(ProfileRepositoryWrapper profileDataProvider, Color userColor, string faceSnapshotUrl, string userId)
{
profilePictureView.SetupWithDependencies(viewDependencies, userColor, faceSnapshotUrl, userId);
profilePictureView.SetupWithDependencies(profileDataProvider, userColor, faceSnapshotUrl, userId);
}

private void Start()
Expand Down
11 changes: 9 additions & 2 deletions Explorer/Assets/DCL/Chat/ChatMessageViewerElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using DCL.Chat.History;
using DCL.Profiles;
using DCL.Diagnostics;
using DCL.Profiles.Helpers;
using DCL.UI.Profiles.Helpers;
using DCL.UI.Utilities;
using DCL.Web3;
Expand Down Expand Up @@ -72,6 +73,7 @@ private enum ChatItemPrefabIndex // It must match the list in the LoopListView.

private IReadOnlyList<ChatMessage>? chatMessages;
private CancellationTokenSource? fadeoutCts;
private ProfileRepositoryWrapper profileRepositoryWrapper;

private int separatorPositionIndex;
private int messageCountWhenSeparatorWasSet;
Expand Down Expand Up @@ -389,12 +391,12 @@ private async UniTaskVoid SetItemDataAsync(int index, ChatMessage itemData, Chat
itemView.usernameElement.userName.color = ProfileNameColorHelper.GetNameColor(itemData.SenderValidatedName);
else
{
Profile? profile = await viewDependencies.GetProfileAsync(itemData.SenderWalletAddress, CancellationToken.None);
Profile? profile = await profileRepositoryWrapper.GetProfileAsync(itemData.SenderWalletAddress, CancellationToken.None);

if (profile != null)
{
itemView.usernameElement.userName.color = profile.UserNameColor;
itemView.ProfilePictureView.SetupWithDependencies(viewDependencies, profile.UserNameColor, profile.Avatar.FaceSnapshotUrl, profile.UserId);
itemView.ProfilePictureView.SetupWithDependencies(profileRepositoryWrapper, profile.UserNameColor, profile.Avatar.FaceSnapshotUrl, profile.UserId);
}
}

Expand Down Expand Up @@ -428,5 +430,10 @@ private void OnEnable()
{
loopList.RefreshAllShownItem(); // This avoids artifacts when new items are added while the object is disabled
}

public void SetProfileDataProvider(ProfileRepositoryWrapper profileRepositoryWrapper)
{
this.profileRepositoryWrapper = profileRepositoryWrapper;
}
}
}
5 changes: 3 additions & 2 deletions Explorer/Assets/DCL/Chat/ChatTitleBarView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cysharp.Threading.Tasks;
using DCL.UI.Profiles.Helpers;
using DCL.UI.ProfileElements;
using DCL.Web3;
using MVC;
Expand Down Expand Up @@ -110,11 +111,11 @@ public void SetNearbyChannelImage()
profileView.gameObject.SetActive(false);
}

public void SetupProfileView(Web3Address userId)
public void SetupProfileView(Web3Address userId, ProfileRepositoryWrapper profileDataProvider)
{
cts = cts.SafeRestart();
profileView.gameObject.SetActive(true);
profileView.SetupAsync(userId, cts.Token).Forget();
profileView.SetupAsync(userId, profileDataProvider, cts.Token).Forget();
nearbyChannelContainer.SetActive(false);
memberCountObject.SetActive(false);
}
Expand Down
14 changes: 12 additions & 2 deletions Explorer/Assets/DCL/Chat/ChatView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using DCL.Settings.Settings;
using DCL.Chat.History;
using DCL.Profiles;
using DCL.UI.Profiles.Helpers;
using DCL.RealmNavigation;
using DCL.UI;
using DCL.Web3;
Expand Down Expand Up @@ -180,6 +181,7 @@ public class ChatView : ViewBase, IView, IViewWithGlobalDependencies, IPointerEn
public event DeleteChatHistoryRequestedDelegate? DeleteChatHistoryRequested;

private ViewDependencies viewDependencies;
private ProfileRepositoryWrapper profileRepositoryWrapper;
private readonly List<ChatMemberListView.MemberData> sortedMemberData = new ();

private IReadOnlyDictionary<ChatChannel.ChannelId, ChatChannel>? channels;
Expand Down Expand Up @@ -267,7 +269,7 @@ public ChatChannel.ChannelId CurrentChannelId
chatTitleBar.SetNearbyChannelImage();
break;
case ChatChannel.ChatChannelType.USER:
chatTitleBar.SetupProfileView(new Web3Address(currentChannel.Id.Id));
chatTitleBar.SetupProfileView(new Web3Address(currentChannel.Id.Id), profileRepositoryWrapper);
break;
}

Expand Down Expand Up @@ -342,6 +344,15 @@ public void SetupInitialConversationToolbarStatusIconForUsers(HashSet<string> us
}
}

public void SetProfileDataPovider(ProfileRepositoryWrapper profileDataProvider)
{
conversationsToolbar.SetProfileDataProvider(profileDataProvider);
memberListView.SetProfileDataProvider(profileDataProvider);
chatMessageViewer.SetProfileDataProvider(profileDataProvider);
chatInputBox.SetProfileDataProvider(profileDataProvider);
this.profileRepositoryWrapper = profileDataProvider;
}

private void Start()
{
IsUnfolded = true;
Expand Down Expand Up @@ -445,7 +456,6 @@ public void InjectDependencies(ViewDependencies dependencies)
chatMessageViewer.InjectDependencies(dependencies);
memberListView.InjectDependencies(dependencies);
chatTitleBar.InjectDependencies(dependencies);
conversationsToolbar.InjectDependencies(dependencies);
}

public void Initialize(IReadOnlyDictionary<ChatChannel.ChannelId, ChatChannel> chatChannels,
Expand Down
2 changes: 1 addition & 1 deletion Explorer/Assets/DCL/Friends/RPCFriendsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using DCL.Profiles;
using DCL.Profiles.Self;
using DCL.SocialService;
using DCL.UI.Profiles.Helpers;
using DCL.Profiles.Helpers;
using DCL.Utilities;
using DCL.Web3;
using Decentraland.SocialService.V2;
Expand Down
Loading
Loading