Skip to content

Commit

Permalink
Execute change Foreground on UI thread
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Dec 14, 2024
1 parent 7f16351 commit 2ae38eb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/PoeLurker.Core/KeyboardLurker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ private async void SearchItem(KeyboardMessageEventArgs e)
private async void OpenPoeTrade(KeyboardMessageEventArgs e)
{
var itemText = await GetClipboardTextAsync();
if (string.IsNullOrEmpty(itemText))
{
return;
}

PoeTradeService.Open(itemText);
}
Expand Down
17 changes: 10 additions & 7 deletions src/PoeLurker.UI/ViewModels/PoeOverlayBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,17 @@ private static double Scale(double value, double scale, bool absolute)
/// <param name="e">if set to <c>true</c> [e].</param>
private void DockingHelper_OnForegroundChange(object sender, bool inForegound)
{
if (inForegound)
{
ShowView();
}
else
Execute.OnUIThread(() =>
{
HideView();
}
if (inForegound)
{
ShowView();
}
else
{
HideView();
}
});
}

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions src/PoeLurker.UI/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ private async void SettingsService_OnSave(object sender, EventArgs e)
}
else
{
await DeactivateItemAsync(_incomingTradeBarOverlay, true, CancellationToken.None);
await Execute.OnUIThreadAsync(() => DeactivateItemAsync(_incomingTradeBarOverlay, true, CancellationToken.None));
}

if (_settingsService.OutgoingTradeEnabled)
Expand Down Expand Up @@ -818,7 +818,7 @@ private void ShowMap(Map item)
{
if (!_popup.IsActive)
{
ActivateItemAsync(_popup);
Execute.OnUIThreadAsync(() => ActivateItemAsync(_popup));
}

if (_settingsService.MapEnabled)
Expand All @@ -841,7 +841,7 @@ private void ShowItemDetails(object sender, PoeItem item)
{
if (!_popup.IsActive)
{
ActivateItemAsync(_popup);
Execute.OnUIThreadAsync(() => ActivateItemAsync(_popup));
}

if (item is Map || item.Rarity == Rarity.Currency || item.Rarity == Rarity.Unique)
Expand Down Expand Up @@ -869,7 +869,7 @@ public Task HandleAsync(Screen screen, CancellationToken token)
return Task.CompletedTask;
}

return ActivateItemAsync(screen);
return Execute.OnUIThreadAsync(() => ActivateItemAsync(screen));
}

/// <summary>
Expand All @@ -880,11 +880,11 @@ public Task HandleAsync(SkillTimelineMessage message, CancellationToken token)
{
if (message.IsVisible)
{
return ActivateItemAsync(_skillTimelineOverlay);
return Execute.OnUIThreadAsync(() => ActivateItemAsync(_skillTimelineOverlay));
}
else
{
return DeactivateItemAsync(_skillTimelineOverlay, true, CancellationToken.None);
return Execute.OnUIThreadAsync(() => DeactivateItemAsync(_skillTimelineOverlay, true, CancellationToken.None));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/PoeLurker.UI/ViewModels/TradebarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ protected override Task OnDeactivateAsync(bool close, CancellationToken token)
_clientLurker.TradeAccepted -= Lurker_TradeAccepted;
_clientLurker.PlayerJoined -= Lurker_PlayerJoined;
_clientLurker.PlayerLeft -= Lurker_PlayerLeft;
TradeOffers.Clear();
Execute.OnUIThread(() => TradeOffers.Clear());
}

return base.OnDeactivateAsync(close, token);
Expand Down

0 comments on commit 2ae38eb

Please sign in to comment.