Deleted old message system. Replaced it with new event system

This commit is contained in:
Marcel Baumgartner
2023-04-21 17:17:10 +02:00
parent b790c31606
commit b8893e7976
14 changed files with 111 additions and 220 deletions

View File

@@ -9,6 +9,7 @@
@using Moonlight.App.Services.Interop
@using Moonlight.App.Services.Sessions
@using Logging.Net
@using Moonlight.App.Events
@layout ThemeInit
@implements IDisposable
@@ -18,7 +19,7 @@
@inject IdentityService IdentityService
@inject SessionService SessionService
@inject NavigationManager NavigationManager
@inject MessageService MessageService
@inject EventSystem Event
@inject ToastService ToastService
<GlobalErrorBoundary>
@@ -164,17 +165,19 @@
NavigationManager.LocationChanged += (sender, args) => { SessionService.Refresh(); };
/*
MessageService.Subscribe<MainLayout, SupportMessage>(
$"support.{User.Id}.message",
this,
async message =>
{
if (!NavigationManager.Uri.EndsWith("/support") && (message.IsSupport || message.IsSystem))
if (User != null)
{
await Event.On<SupportChatMessage>(
$"supportChat.{User.Id}.message",
this,
async message =>
{
await ToastService.Info($"Support: {message.Message}");
}
});*/
if (!NavigationManager.Uri.EndsWith("/support") && message.Sender != User)
{
await ToastService.Info($"Support: {message.Content}");
}
});
}
RunDelayedMenu(0);
RunDelayedMenu(1);
@@ -188,13 +191,13 @@
}
}
public void Dispose()
public async void Dispose()
{
SessionService.Close();
if (User != null)
{
MessageService.Unsubscribe($"support.{User.Id}.message", this);
await Event.Off($"supportChat.{User.Id}.message", this);
}
}