Apply shared ticket activity capability to overview rows
This commit is contained in:
@@ -24,7 +24,7 @@ namespace FasdDesktopUi.Basics.Services
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private const string ServiceRequestsEnabledKey = "ServiceRequestsEnabled";
|
||||
private const string TicketAndServiceRequestsEnabledKey = "TicketAndServiceRequestsEnabled";
|
||||
private readonly ITicketOverviewCommunicationSource _communicationSource;
|
||||
private static readonly string[] OverviewKeys = new[]
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace FasdDesktopUi.Basics.Services
|
||||
private bool _isDemo;
|
||||
private bool _initialized;
|
||||
private bool _isEnabled;
|
||||
private bool _serviceRequestsEnabled;
|
||||
private bool _ticketAndServiceRequestsEnabled;
|
||||
private readonly Random _random = new Random();
|
||||
#if isDemo
|
||||
private readonly List<DemoTicketRecord> _persistedDemoTickets = new List<DemoTicketRecord>();
|
||||
@@ -115,10 +115,10 @@ namespace FasdDesktopUi.Basics.Services
|
||||
#region Public API
|
||||
|
||||
public event EventHandler<TicketOverviewCountsChangedEventArgs> OverviewCountsChanged;
|
||||
public event EventHandler ServiceRequestsAvailabilityChanged;
|
||||
public event EventHandler TicketAndServiceRequestsAvailabilityChanged;
|
||||
|
||||
public IReadOnlyDictionary<string, TileCounts> CurrentCounts => _currentCounts;
|
||||
public bool ServiceRequestsEnabled => _serviceRequestsEnabled;
|
||||
public bool TicketAndServiceRequestsEnabled => _ticketAndServiceRequestsEnabled;
|
||||
|
||||
public bool IsScopeInitialized(TileScope scope)
|
||||
{
|
||||
@@ -224,7 +224,7 @@ namespace FasdDesktopUi.Basics.Services
|
||||
_currentCounts[key] = TileCounts.Empty;
|
||||
}
|
||||
|
||||
UpdateServiceRequestsAvailability(false);
|
||||
UpdateTicketAndServiceRequestsAvailability(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -339,11 +339,11 @@ namespace FasdDesktopUi.Basics.Services
|
||||
_isDemo = communication.IsDemo();
|
||||
|
||||
var requestedKeys = scope == TileScope.Personal
|
||||
? OverviewKeys.Concat(new[] { ServiceRequestsEnabledKey }).ToArray()
|
||||
? OverviewKeys.Concat(new[] { TicketAndServiceRequestsEnabledKey }).ToArray()
|
||||
: OverviewKeys;
|
||||
var rawCounts = await communication.GetTicketOverviewCounts(requestedKeys, scope == TileScope.Role).ConfigureAwait(false);
|
||||
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
var serviceRequestsEnabled = _isDemo;
|
||||
var ticketAndServiceRequestsEnabled = _isDemo;
|
||||
|
||||
if (rawCounts != null)
|
||||
{
|
||||
@@ -352,10 +352,10 @@ namespace FasdDesktopUi.Basics.Services
|
||||
if (string.IsNullOrWhiteSpace(kvp.Key))
|
||||
continue;
|
||||
|
||||
if (string.Equals(kvp.Key, ServiceRequestsEnabledKey, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(kvp.Key, TicketAndServiceRequestsEnabledKey, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (scope == TileScope.Personal)
|
||||
serviceRequestsEnabled = _isDemo || kvp.Value > 0;
|
||||
ticketAndServiceRequestsEnabled = _isDemo || kvp.Value > 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ namespace FasdDesktopUi.Basics.Services
|
||||
await _dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
if (scope == TileScope.Personal)
|
||||
UpdateServiceRequestsAvailability(serviceRequestsEnabled);
|
||||
UpdateTicketAndServiceRequestsAvailability(ticketAndServiceRequestsEnabled);
|
||||
|
||||
ProcessScopeCounts(scope, counts);
|
||||
});
|
||||
@@ -389,13 +389,13 @@ namespace FasdDesktopUi.Basics.Services
|
||||
|
||||
#region Count Processing
|
||||
|
||||
private void UpdateServiceRequestsAvailability(bool isEnabled)
|
||||
private void UpdateTicketAndServiceRequestsAvailability(bool isEnabled)
|
||||
{
|
||||
if (_serviceRequestsEnabled == isEnabled)
|
||||
if (_ticketAndServiceRequestsEnabled == isEnabled)
|
||||
return;
|
||||
|
||||
_serviceRequestsEnabled = isEnabled;
|
||||
ServiceRequestsAvailabilityChanged?.Invoke(this, EventArgs.Empty);
|
||||
_ticketAndServiceRequestsEnabled = isEnabled;
|
||||
TicketAndServiceRequestsAvailabilityChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void RefreshTimerIntervals()
|
||||
|
||||
Reference in New Issue
Block a user