diff --git a/BTCPayServer/Hubs/CrowdfundHub.cs b/BTCPayServer/Hubs/CrowdfundHub.cs index ee7dc46ee..32e97f385 100644 --- a/BTCPayServer/Hubs/CrowdfundHub.cs +++ b/BTCPayServer/Hubs/CrowdfundHub.cs @@ -22,11 +22,11 @@ namespace BTCPayServer.Hubs { public class CrowdfundHub: Hub { - private readonly IServiceProvider _ServiceProvider; + private readonly AppsPublicController _AppsPublicController; - public CrowdfundHub(IServiceProvider serviceProvider) + public CrowdfundHub(AppsPublicController appsPublicController) { - _ServiceProvider = serviceProvider; + _AppsPublicController = appsPublicController; } public async Task ListenToCrowdfundApp(string appId) { @@ -42,16 +42,12 @@ namespace BTCPayServer.Hubs public async Task CreateInvoice(ContributeToCrowdfund model) { - using (var scope = _ServiceProvider.CreateScope()) - { - var controller = scope.ServiceProvider.GetService(); model.RedirectToCheckout = false; - controller.ControllerContext.HttpContext = Context.GetHttpContext(); - var result = await controller.ContributeToCrowdfund(Context.Items["app"].ToString(), model); + _AppsPublicController.ControllerContext.HttpContext = Context.GetHttpContext(); + var result = await _AppsPublicController.ContributeToCrowdfund(Context.Items["app"].ToString(), model); await Clients.Caller.SendCoreAsync("InvoiceCreated", new[] {(result as OkObjectResult)?.Value.ToString()}); - } - } + } public class CrowdfundHubStreamer @@ -155,7 +151,12 @@ namespace BTCPayServer.Hubs { _CacheTokens[appId].Cancel(); } - _HubContext.Clients.Group(appId).SendCoreAsync("InfoUpdated", Array.Empty() ); + + GetCrowdfundInfo(appId).ContinueWith(task => + { + _HubContext.Clients.Group(appId).SendCoreAsync("InfoUpdated", new object[]{ task.Result} ); + }, TaskScheduler.Default); + } private static async Task GetCurrentContributionAmount(InvoiceEntity[] invoices, string primaryCurrency, diff --git a/BTCPayServer/wwwroot/crowdfund/app.js b/BTCPayServer/wwwroot/crowdfund/app.js index e22c4a637..99e108ab6 100644 --- a/BTCPayServer/wwwroot/crowdfund/app.js +++ b/BTCPayServer/wwwroot/crowdfund/app.js @@ -77,7 +77,6 @@ addLoadEvent(function (ev) { self.thankYouModalOpen = true; }; eventAggregator.$on("payment-received", function (amount, cryptoCode, type) { - console.warn("AAAAAA", arguments); var onChain = type.toLowerCase() === "btclike"; playRandomQuakeSound(); fireworks(); @@ -97,16 +96,17 @@ addLoadEvent(function (ev) { }); eventAggregator.$on("info-updated", function (model) { - this.srvModel = model; + console.warn("UPDATED", self.srvModel, arguments); + self.srvModel = model; }); eventAggregator.$on("connection-pending", function () { - this.connectionStatus = "pending"; + self.connectionStatus = "pending"; }); eventAggregator.$on("connection-failed", function () { - this.connectionStatus = "failed"; + self.connectionStatus = "failed"; }); eventAggregator.$on("connection-lost", function () { - this.connectionStatus = "connection lost"; + self.connectionStatus = "connection lost"; }); this.updateComputed(); }