feat: Introduce ITranscriptionOrchestrator and related interfaces, refactoring DaemonService and other components to use dependency injection.
This commit is contained in:
@@ -2,14 +2,23 @@ using System.Diagnostics;
|
||||
|
||||
using Toak.Core;
|
||||
|
||||
using Toak.Core.Interfaces;
|
||||
|
||||
namespace Toak.IO;
|
||||
|
||||
public static class TextInjector
|
||||
public class TextInjector : ITextInjector
|
||||
{
|
||||
public static void Inject(string text, string backend)
|
||||
private readonly INotifications _notifications;
|
||||
|
||||
public TextInjector(INotifications notifications)
|
||||
{
|
||||
_notifications = notifications;
|
||||
}
|
||||
|
||||
public Task InjectTextAsync(string text, string backend = "xdotool")
|
||||
{
|
||||
Logger.LogDebug($"Injecting text: '{text}' with {backend}");
|
||||
if (string.IsNullOrWhiteSpace(text)) return;
|
||||
if (string.IsNullOrWhiteSpace(text)) return Task.CompletedTask;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -42,11 +51,12 @@ public static class TextInjector
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[TextInjector] Error injecting text: {ex.Message}");
|
||||
Notifications.Notify("Injection Error", "Could not type text into window.");
|
||||
_notifications.Notify("Injection Error", "Could not type text into window.");
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public static async Task<string> InjectStreamAsync(IAsyncEnumerable<string> tokenStream, string backend)
|
||||
public async Task<string> InjectStreamAsync(IAsyncEnumerable<string> tokenStream, string backend)
|
||||
{
|
||||
string fullText = string.Empty;
|
||||
try
|
||||
@@ -97,7 +107,7 @@ public static class TextInjector
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[TextInjector] Error injecting text stream: {ex.Message}");
|
||||
Notifications.Notify("Injection Error", "Could not type text stream into window.");
|
||||
_notifications.Notify("Injection Error", "Could not type text stream into window.");
|
||||
}
|
||||
return fullText;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user