From 6932fdc88322b60e1ec1da7474edf0caab5e956d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 11 Jul 2020 18:57:04 +0100 Subject: [PATCH] EDDB: Use CAPI for system_address/station_marketid only if not already set See issue #586 - a user had incorrect system_address set, but only sometimes. This could possibly be due to CAPI errors/lag, so only use it as the source when the values aren't yet set. Otherwise Journal should always have provided the correct value in a timely manner. --- plugins/eddb.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/eddb.py b/plugins/eddb.py index 9c17b497..f0e31ba6 100644 --- a/plugins/eddb.py +++ b/plugins/eddb.py @@ -69,10 +69,16 @@ def journal_entry(cmdr, is_beta, system, station, entry, state): def cmdr_data(data, is_beta): if config.get('system_provider') == 'eddb': - this.system_address = data['lastSystem']['id'] or this.system_address - this.system_link['url'] = system_url(this.system_address) # Override standard URL function + # Only fill in system_address from CAPI if it's not set yet + # This is to avoid CAPI lagging causing incorrect value + if not this.system_address: + this.system_address = data['lastSystem']['id'] + this.system_link['url'] = system_url(this.system_address) # Override standard URL function if config.get('station_provider') == 'eddb': - this.station_marketid = data['commander']['docked'] and data['lastStarport']['id'] - this.station_link['text'] = data['commander']['docked'] and data['lastStarport']['name'] or (data['lastStarport']['name'] and data['lastStarport']['name'] != "" and STATION_UNDOCKED or '') - this.station_link.update_idletasks() + # Only use CAPI value if not yet set + # This is to avoid CAPI lagging causing incorrect value + if not this.station_marketid: + this.station_marketid = data['commander']['docked'] and data['lastStarport']['id'] + this.station_link['text'] = data['commander']['docked'] and data['lastStarport']['name'] or (data['lastStarport']['name'] and data['lastStarport']['name'] != "" and STATION_UNDOCKED or '') + this.station_link.update_idletasks()