mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 23:34:10 +02:00
Add hex color parsing helper and implement custom list sources for channels and users
- Introduced HexColorHelper for parsing hex color strings to Terminal.Gui Attributes and Colors. - Created ChannelListSource for managing and rendering a list of channels with unread counts and active indicators. - Developed UserListSource for displaying online users with per-user nickname colors. - Refactored MainWindow to utilize ChatMessageManager for handling messages and channel state. - Updated project references and removed unused content from the server project. - Adjusted tests to reflect changes in namespaces and structure.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Serilog;
|
||||
using Terminal.Gui.App;
|
||||
|
||||
namespace EchoHub.Client.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Eliminates repeated Task.Run/try/catch/app.Invoke(ShowError) boilerplate.
|
||||
/// Runs async work on a background thread and routes exceptions to the UI.
|
||||
/// </summary>
|
||||
public static class AsyncRunner
|
||||
{
|
||||
public static void Run(
|
||||
IApplication app,
|
||||
Func<Task> work,
|
||||
Action<string> showError,
|
||||
string errorPrefix,
|
||||
string? logContext = null)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await work();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "{Context} failed", logContext ?? errorPrefix);
|
||||
app.Invoke(() => showError($"{errorPrefix}: {ex.Message}"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user