mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 16:46:08 +02:00
feat: Add Create Channel dialog and related events
- Introduced CreateChannelDialog for user to create new channels with name and topic. - Added OnCreateChannelRequested event in MainWindow for channel creation. - Enhanced EchoHubConnection with OnReconnected event for connection state handling. - Updated EchoHubDbContext to use application base directory for SQLite database path. - Integrated Serilog for logging in EchoHub.Server. - Refactored database initialization and migration logic into DatabaseSetup class. - Implemented FirstRunSetup to ensure appsettings.json and generate JWT secret if needed. - Updated appsettings files to configure Serilog logging. - Enhanced error handling and logging in ChatHub methods for better traceability.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Serilog;
|
||||
using Terminal.Gui.App;
|
||||
|
||||
namespace EchoHub.Client;
|
||||
|
||||
/// <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