Skip to content

Commit 44852f0

Browse files
claude review
1 parent 574e004 commit 44852f0

4 files changed

Lines changed: 11 additions & 13 deletions

File tree

Explorer/Assets/DCL/Communities/CommunityDataService/CommunityDataService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using DCL.Web3.Identities;
1414
using Decentraland.SocialService.V2;
1515
using MVC;
16+
using UnityEngine.Pool;
1617
using Utility;
1718

1819
namespace DCL.Communities
@@ -239,9 +240,8 @@ private void CommunityDeleted(string communityId)
239240

240241
public void SetCommunities(IEnumerable<GetUserCommunitiesData.CommunityData> newCommunities)
241242
{
242-
string[] previouslyJoined = joinedCommunityIds.Count == 0 ? Array.Empty<string>() : new string[joinedCommunityIds.Count];
243-
if (previouslyJoined.Length > 0)
244-
joinedCommunityIds.CopyTo(previouslyJoined);
243+
using PooledObject<HashSet<string>> _ = HashSetPool<string>.Get(out HashSet<string> previouslyJoined);
244+
previouslyJoined.UnionWith(joinedCommunityIds);
245245

246246
communities.Clear();
247247
joinedCommunityIds.Clear();
@@ -257,7 +257,7 @@ public void SetCommunities(IEnumerable<GetUserCommunitiesData.CommunityData> new
257257
CommunityRemoved?.Invoke(id);
258258

259259
foreach (string id in joinedCommunityIds)
260-
if (Array.IndexOf(previouslyJoined, id) < 0)
260+
if (!previouslyJoined.Contains(id))
261261
CommunityJoined?.Invoke(id);
262262
}
263263

Explorer/Assets/DCL/ExplorePanel/ExplorePanelController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ExplorePanelController : ControllerBase<ExplorePanelView, ExplorePa
4646
private readonly JoinedCommunitiesVoiceLiveTracker communitiesLiveTracker;
4747
private bool includeCommunities;
4848

49-
private IDisposable? communitiesLiveBadgeSubscription;
49+
private ReactivePropertyExtensions.DisposableSubscription<bool> communitiesLiveBadgeSubscription;
5050

5151
private Dictionary<ExploreSections, TabSelectorView> tabsBySections;
5252
private Dictionary<ExploreSections, ISection> exploreSections;
@@ -121,8 +121,7 @@ public override void Dispose()
121121
setupExploreSectionsCts.SafeCancelAndDispose();
122122
checkForLiveEventsCts.SafeCancelAndDispose();
123123

124-
communitiesLiveBadgeSubscription?.Dispose();
125-
communitiesLiveBadgeSubscription = null;
124+
communitiesLiveBadgeSubscription.Dispose();
126125
}
127126

128127
private async UniTaskVoid OnShowSectionFromNotificationAsync(object[] _, ExploreSections sectionToShow)

Explorer/Assets/DCL/UI/Sidebar/SidebarController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class SidebarController : ControllerBase<SidebarView>
6767
private readonly bool isNearbyVoiceChatEnabled;
6868
private readonly HttpEventsApiService eventsApiService;
6969

70-
private IDisposable? communitiesLiveBadgeSubscription;
70+
private ReactivePropertyExtensions.DisposableSubscription<bool> communitiesLiveBadgeSubscription;
7171

7272
private readonly CancellationTokenSource profileWidgetCts = new ();
7373
private CancellationTokenSource checkForLiveEventsCts = new ();
@@ -174,8 +174,7 @@ public override void Dispose()
174174
openPanelCts.SafeCancelAndDispose();
175175
checkForLiveEventsCts.SafeCancelAndDispose();
176176

177-
communitiesLiveBadgeSubscription?.Dispose();
178-
communitiesLiveBadgeSubscription = null;
177+
communitiesLiveBadgeSubscription.Dispose();
179178
}
180179

181180
private void OnChatStateChanged(ChatEvents.ChatStateChangedEvent eventData) =>

Explorer/Assets/DCL/VoiceChat/CommunityVoiceChat/JoinedCommunitiesVoiceLiveTracker.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class JoinedCommunitiesVoiceLiveTracker : IDisposable
1010
private readonly ICommunityCallOrchestrator orchestrator;
1111
private readonly ICommunityDataService communityDataService;
1212

13-
private readonly Dictionary<string, IDisposable> perCommunitySubscriptions = new ();
13+
private readonly Dictionary<string, ReactivePropertyExtensions.DisposableSubscription<bool>> perCommunitySubscriptions = new ();
1414
private readonly HashSet<string> liveJoinedCommunityIds = new ();
1515
private readonly ReactiveProperty<bool> hasAnyJoinedCommunityLive = new (false);
1616

@@ -60,7 +60,7 @@ private void AddSubscription(string communityId)
6060

6161
private void RemoveSubscription(string communityId)
6262
{
63-
if (perCommunitySubscriptions.TryGetValue(communityId, out IDisposable? subscription))
63+
if (perCommunitySubscriptions.TryGetValue(communityId, out var subscription))
6464
{
6565
subscription.Dispose();
6666
perCommunitySubscriptions.Remove(communityId);
@@ -87,7 +87,7 @@ public void Dispose()
8787
communityDataService.CommunityJoined -= OnCommunityJoined;
8888
communityDataService.CommunityRemoved -= OnCommunityRemoved;
8989

90-
foreach (IDisposable subscription in perCommunitySubscriptions.Values)
90+
foreach (var subscription in perCommunitySubscriptions.Values)
9191
subscription.Dispose();
9292

9393
perCommunitySubscriptions.Clear();

0 commit comments

Comments
 (0)