Skip to content

Commit a0e665a

Browse files
authored
fix: proper cleanup of outfit state on panel close (#8832)
1 parent b2979e7 commit a0e665a

3 files changed

Lines changed: 34 additions & 14 deletions

File tree

Explorer/Assets/DCL/Backpack/AvatarSection/Outfits/OutfitsPresenter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public void Activate()
119119

120120
public void Deactivate()
121121
{
122+
foreach (var presenter in slotPresenters)
123+
presenter.ResetHoverState();
124+
122125
EndSlotBusy();
123126
characterPreviewController.StopEmotes();
124127
previewOutfitCommand.Restore();

Explorer/Assets/DCL/Backpack/AvatarSection/Outfits/Slots/OutfitSlotPresenter.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,13 @@ public class OutfitSlotPresenter : IDisposable
3737
public event Action<OutfitItem>? OnEquipRequested;
3838
public event Action<OutfitItem>? OnPreviewRequested;
3939

40-
public bool HasThumbnail()
41-
{
42-
return currentThumbnail != null;
43-
}
44-
4540
public readonly int slotIndex;
4641

4742
private readonly OutfitSlotView view;
4843
private readonly HoverHandler hoverHandler;
4944
private readonly IAvatarScreenshotService screenshotService;
5045
private CancellationTokenSource cts = new ();
51-
46+
5247
private bool isHovered;
5348
private bool isForcedHover;
5449
private OutfitSlotState currentState;
@@ -67,16 +62,17 @@ public OutfitSlotPresenter( OutfitSlotView view,
6762
view.OnDeleteClicked += HandleDeleteClicked;
6863
view.OnEquipClicked += HandleEquipClicked;
6964
view.OnPreviewClicked += HandlePreviewClicked;
70-
65+
7166
hoverHandler = view.hoverHandler;
7267
hoverHandler.OnHoverEntered += OnHoverEntered;
7368
hoverHandler.OnHoverExited += OnHoverExited;
7469
}
7570

76-
public OutfitItem? GetOutfitData()
77-
{
78-
return currentOutfitData;
79-
}
71+
public bool HasThumbnail() =>
72+
currentThumbnail != null;
73+
74+
public OutfitItem? GetOutfitData() =>
75+
currentOutfitData;
8076

8177
private void HandleSaveClicked()
8278
{
@@ -176,6 +172,13 @@ public void SetEquipLoading(bool loading) =>
176172
public void SetHoverEnabled(bool isEnabled) =>
177173
view.SetHoverEnabled(isEnabled);
178174

175+
public void ResetHoverState()
176+
{
177+
isHovered = false;
178+
view.ResetHoverState();
179+
UpdateView();
180+
}
181+
179182
private void SetState(OutfitSlotState newState, OutfitItem? item = null)
180183
{
181184
currentState = newState;
@@ -185,8 +188,8 @@ private void SetState(OutfitSlotState newState, OutfitItem? item = null)
185188

186189
private void UpdateView()
187190
{
188-
bool effectiveHover = isHovered || isForcedHover;
189-
191+
bool effectiveHover = isHovered || isForcedHover;
192+
190193
switch (currentState)
191194
{
192195
case OutfitSlotState.Empty: view.ShowEmptyState(isHovered); break;
@@ -275,4 +278,4 @@ public void PlaySaveOutfitSound()
275278
view.PlaySaveOutfitSound();
276279
}
277280
}
278-
}
281+
}

Explorer/Assets/DCL/Backpack/AvatarSection/Outfits/Slots/OutfitSlotView.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ public void SetHoverEnabled(bool isEnabled)
226226
hoverHandler.enabled = isEnabled;
227227
}
228228

229+
public void ResetHoverState()
230+
{
231+
cts?.SafeCancelAndDispose();
232+
cts = null;
233+
234+
transform.localScale = Vector3.one;
235+
236+
if (outfitHoverOutline != null)
237+
{
238+
outfitHoverOutline.transform.localScale = Vector3.zero;
239+
outfitHoverOutline.gameObject.SetActive(false);
240+
}
241+
}
242+
229243
private void ResetEquipButtonContent()
230244
{
231245
isEquipLoading = false;

0 commit comments

Comments
 (0)