only create filter provider if download is complete
This commit is contained in:
parent
14c14f7626
commit
3eccbaa8b8
14
EDDB/API.cs
14
EDDB/API.cs
@ -10,6 +10,10 @@ namespace NonaBGS.EDDB {
|
|||||||
|
|
||||||
private string systems_file = null;
|
private string systems_file = null;
|
||||||
|
|
||||||
|
public delegate void DatabaseAvailableDelegate();
|
||||||
|
|
||||||
|
public event DatabaseAvailableDelegate SystemsAvailable;
|
||||||
|
|
||||||
public string SystemsFile => systems_file;
|
public string SystemsFile => systems_file;
|
||||||
|
|
||||||
public string Cache {
|
public string Cache {
|
||||||
@ -27,13 +31,15 @@ namespace NonaBGS.EDDB {
|
|||||||
client.DownloadDataCompleted += Client_DownloadDataCompleted;
|
client.DownloadDataCompleted += Client_DownloadDataCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DownloadFile(string url, string file) {
|
private void DownloadFile(string url, string file, DatabaseAvailableDelegate notifier) {
|
||||||
client.DownloadFileAsync(new Uri(url), file);
|
client.DownloadFileAsync(new Uri(url), file, notifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Download(bool force) {
|
public void Download(bool force) {
|
||||||
if (!HaveSystemsFile || force) {
|
if (!HaveSystemsFile || force) {
|
||||||
DownloadFile(EDDB_SYSTEMS_ARCHIVE, systems_file);
|
DownloadFile(EDDB_SYSTEMS_ARCHIVE, systems_file, SystemsAvailable);
|
||||||
|
} else if (HaveSystemsFile) {
|
||||||
|
SystemsAvailable?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +60,8 @@ namespace NonaBGS.EDDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) {
|
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) {
|
||||||
|
DatabaseAvailableDelegate notifier = e.UserState as DatabaseAvailableDelegate;
|
||||||
|
notifier?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,6 @@ namespace NonaBGS {
|
|||||||
private Report report = new Report();
|
private Report report = new Report();
|
||||||
private Config config = new Config();
|
private Config config = new Config();
|
||||||
private API api = null;
|
private API api = null;
|
||||||
private PopulatedSystems systems_db = null;
|
|
||||||
private SystemSuggestionProvider systems_provider = null;
|
|
||||||
|
|
||||||
public Config Config => config;
|
public Config Config => config;
|
||||||
|
|
||||||
@ -54,12 +52,19 @@ namespace NonaBGS {
|
|||||||
Log(e.Message);
|
Log(e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api.SystemsAvailable += Api_SystemsAvailable;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SyncDatabases();
|
SyncDatabases();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
systems_db = api.MakePopulatedSystems();
|
private void Api_SystemsAvailable() {
|
||||||
systems_provider = new SystemSuggestionProvider(systems_db);
|
try {
|
||||||
system.Provider = systems_provider;
|
var systems_db = api.MakePopulatedSystems();
|
||||||
|
system.Provider = new SystemSuggestionProvider(systems_db);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log(e.Message);
|
Log(e.Message);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user