Ship list WIP
This commit is contained in:
parent
b26fff7e17
commit
8f40b82c5d
@ -144,9 +144,12 @@ namespace BreCalClient
|
|||||||
|
|
||||||
internal static void InitializeShips(List<Ship> ships)
|
internal static void InitializeShips(List<Ship> ships)
|
||||||
{
|
{
|
||||||
|
_ships.Clear();
|
||||||
|
_allShips.Clear();
|
||||||
|
|
||||||
foreach (var ship in ships)
|
foreach (var ship in ships)
|
||||||
{
|
{
|
||||||
ShipModel sm = new ShipModel(ship);
|
ShipModel sm = new(ship);
|
||||||
_shipLookupDict[ship.Id] = sm;
|
_shipLookupDict[ship.Id] = sm;
|
||||||
if (!ship.Deleted)
|
if (!ship.Deleted)
|
||||||
_ships.Add(sm);
|
_ships.Add(sm);
|
||||||
|
|||||||
@ -34,6 +34,7 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
private readonly ILog _log = LogManager.GetLogger(typeof(MainWindow));
|
private readonly ILog _log = LogManager.GetLogger(typeof(MainWindow));
|
||||||
private const int SHIPCALL_UPDATE_INTERVAL_SECONDS = 30;
|
private const int SHIPCALL_UPDATE_INTERVAL_SECONDS = 30;
|
||||||
|
private const int SHIPS_UPDATE_INTERVAL_SECONDS = 120;
|
||||||
private const int PROGRESS_STEPS = 50;
|
private const int PROGRESS_STEPS = 50;
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
@ -429,6 +430,18 @@ namespace BreCalClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ = Task.Run(() => RefreshShipcalls());
|
_ = Task.Run(() => RefreshShipcalls());
|
||||||
|
|
||||||
|
_ = Task.Run(() => RefreshShips());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task RefreshShips()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Thread.Sleep(SHIPS_UPDATE_INTERVAL_SECONDS * 1000);
|
||||||
|
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RefreshShipcalls()
|
public async Task RefreshShipcalls()
|
||||||
|
|||||||
Reference in New Issue
Block a user