Skip to content

Commit e4fc3da

Browse files
authored
Merge pull request #4407 from decentraland/fix/chat-show-on-loading-status-complete
fix: prevent initializing the chat until loading is completed (Null Reference Exceptions in chat subsystem)
2 parents c8d827c + b2e77ca commit e4fc3da

1 file changed

Lines changed: 4 additions & 31 deletions

File tree

Explorer/Assets/DCL/PluginSystem/Global/ChatPlugin.cs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -183,47 +183,20 @@ public async UniTask InitializeAsync(ChatPluginSettings settings, CancellationTo
183183

184184
// Log out / log in
185185
web3IdentityCache.OnIdentityCleared += OnIdentityCleared;
186-
web3IdentityCache.OnIdentityChanged += OnIdentityChanged;
187-
188-
realmData.RealmType.OnUpdate += OnRealmChange;
189-
realmNavigator.NavigationExecuted += OnNavigationExecuted;
190-
}
191-
192-
/// <summary>
193-
/// TODO: This is a temporary solution to show the chat when the user navigates to a parcel.
194-
/// NOTE: check this PR for more details:
195-
/// https://github.com/decentraland/unity-explorer/issues/4324
196-
/// </summary>
197-
/// <param name="parcel"></param>
198-
private void OnNavigationExecuted(Vector2Int parcel)
199-
{
200-
sharedSpaceManager.ShowAsync(PanelsSharingSpace.Chat, new ChatControllerShowParams(true,false)).Forget();
186+
loadingStatus.CurrentStage.OnUpdate += OnLoadingStatusUpdate;
201187
}
202188

203-
/// <summary>
204-
/// TODO: This is a temporary solution to show the chat when the user changes realm.
205-
/// NOTE: check this PR for more details:
206-
/// https://github.com/decentraland/unity-explorer/issues/4324
207-
/// </summary>
208-
/// <param name="realmKind"></param>
209-
private void OnRealmChange(RealmKind realmKind)
189+
private void OnLoadingStatusUpdate(LoadingStatus.LoadingStage status)
210190
{
211-
sharedSpaceManager.ShowAsync(PanelsSharingSpace.Chat, new ChatControllerShowParams(true,false)).Forget();
191+
if (status == LoadingStatus.LoadingStage.Completed)
192+
sharedSpaceManager.ShowAsync(PanelsSharingSpace.Chat, new ChatControllerShowParams(true, false)).Forget();
212193
}
213194

214195
private void OnIdentityCleared()
215196
{
216197
if (chatController.IsVisibleInSharedSpace)
217198
chatController.HideViewAsync(CancellationToken.None).Forget();
218199
}
219-
220-
private void OnIdentityChanged()
221-
{
222-
//This might pose a problem if we havent logged in yet (so we change session before first login), it works, but we are trying to show the chat twice
223-
//Once from here and once from the MainUIController. We need to account for this.
224-
225-
sharedSpaceManager.ShowAsync(PanelsSharingSpace.Chat, new ChatControllerShowParams(true, false)).Forget();
226-
}
227200
}
228201

229202
public class ChatPluginSettings : IDCLPluginSettings

0 commit comments

Comments
 (0)