mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-13 00:23:59 -07:00
Instant progress notifications. Now use comet instead of pooling.
This commit is contained in:
parent
9a251394da
commit
a1caa789fe
5 changed files with 57 additions and 39 deletions
|
@ -1,4 +1,7 @@
|
|||
using System.Web.Mvc;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Web.Mvc;
|
||||
using MvcMiniProfiler;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
|
@ -32,8 +35,8 @@ namespace NzbDrone.Web.Controllers
|
|||
|
||||
else
|
||||
{
|
||||
if (_notifications.GetProgressNotifications.Count != 0)
|
||||
message = _notifications.GetProgressNotifications[0].CurrentMessage;
|
||||
if (_notifications.ProgressNotifications.Count != 0)
|
||||
message = _notifications.ProgressNotifications[0].CurrentMessage;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,5 +47,33 @@ namespace NzbDrone.Web.Controllers
|
|||
|
||||
return Json(message, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult Comet(string message)
|
||||
{
|
||||
var requestTimer = Stopwatch.StartNew();
|
||||
|
||||
MiniProfiler.Stop(true);
|
||||
|
||||
var currentMessage = GetCurrentMessage();
|
||||
|
||||
while (message == currentMessage && requestTimer.Elapsed.TotalSeconds < 10)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
currentMessage = GetCurrentMessage();
|
||||
}
|
||||
|
||||
return Json(currentMessage, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
private string GetCurrentMessage()
|
||||
{
|
||||
if (_notifications.ProgressNotifications.Count != 0)
|
||||
return _notifications.ProgressNotifications[0].CurrentMessage;
|
||||
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue