diff --git a/PizzaBot/Components/GlobalMessages.razor b/PizzaBot/Components/GlobalMessages.razor index a55cdcf..eea9d0c 100644 --- a/PizzaBot/Components/GlobalMessages.razor +++ b/PizzaBot/Components/GlobalMessages.razor @@ -1,4 +1,5 @@ @inject GlobalStuffService GlobalStuffService +@rendermode InteractiveServer @if (GlobalStuffService.OrdersLocked) { @@ -9,3 +10,19 @@

@GlobalStuffService.Message

} + +@code{ + protected override void OnInitialized() + { + EventHandler Reload = async (sender, eventArgs) => + { + await InvokeAsync(StateHasChanged); + }; + GlobalStuffService.OnLockOrMessageChange += Reload; + } + + + void ReloadState(){ + StateHasChanged(); + } +} diff --git a/PizzaBot/Services/GlobalStuffService.cs b/PizzaBot/Services/GlobalStuffService.cs index ae69ddf..a2ab5f3 100644 --- a/PizzaBot/Services/GlobalStuffService.cs +++ b/PizzaBot/Services/GlobalStuffService.cs @@ -11,6 +11,7 @@ namespace PizzaBot.Services private bool _ordersLocked; public readonly string LOCKED_ORDERS_MESSAGE = "Orders have been locked. Pizza will be ordered soon."; + public event EventHandler OnLockOrMessageChange; public int MeatPizzas { get; set; } public int VeggiePizzas { get; set; } public int VeganPizzas { get; set; } @@ -32,6 +33,7 @@ namespace PizzaBot.Services public void SetMessage(string message) { _message = message; + OnLockOrMessageChange(this, null); } public void SetOrdersLocked(bool ordersLocked) @@ -39,6 +41,7 @@ namespace PizzaBot.Services _ordersLocked = ordersLocked; ShouldBalance = true; + OnLockOrMessageChange(this, null); } public PizzaConfig? GetConfig()