1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 20:10:11 +03:00

Cache assitnow offline data.

Allows for offline use.
This commit is contained in:
Marcelo Bezerra 2024-06-23 22:10:53 +02:00
parent 152124627c
commit a3778ae40f
3 changed files with 21 additions and 3 deletions

View file

@ -78,6 +78,7 @@ $(function() {
$('a', activeTab).trigger('click'); $('a', activeTab).trigger('click');
} }
globalSettings.store = store;
globalSettings.unitType = store.get('unit_type', UnitType.none); globalSettings.unitType = store.get('unit_type', UnitType.none);
globalSettings.mapProviderType = store.get('map_provider_type', 'osm'); globalSettings.mapProviderType = store.get('map_provider_type', 'osm');
globalSettings.mapApiKey = store.get('map_api_key', ''); globalSettings.mapApiKey = store.get('map_api_key', '');
@ -85,6 +86,8 @@ $(function() {
globalSettings.proxyURL = store.get('proxyurl', 'http://192.168.1.222/mapproxy/service?'); globalSettings.proxyURL = store.get('proxyurl', 'http://192.168.1.222/mapproxy/service?');
globalSettings.proxyLayer = store.get('proxylayer', 'your_proxy_layer_name'); globalSettings.proxyLayer = store.get('proxylayer', 'your_proxy_layer_name');
globalSettings.showProfileParameters = store.get('show_profile_parameters', 1); globalSettings.showProfileParameters = store.get('show_profile_parameters', 1);
globalSettings.assistnowOfflineData = store.get('assistnow_offline_data', []);
globalSettings.assistnowOfflineDate = store.get('assistnow_offline_date', 0);
updateProfilesHighlightColours(); updateProfilesHighlightColours();
var cliAutocomplete = store.get('cli_autocomplete', true); var cliAutocomplete = store.get('cli_autocomplete', true);

View file

@ -22,6 +22,13 @@ var globalSettings = {
docsTreeLocation: 'master', docsTreeLocation: 'master',
cliAutocomplete: true, cliAutocomplete: true,
assistnowApiKey: null, assistnowApiKey: null,
assistnowOfflineData: [],
assistnowOfflineDate: 0,
store: null,
saveAssistnowData: function() {
this.store.set('assistnow_offline_data', this.assistnowOfflineData);
this.store.set('assistnow_offline_date', this.assistnowOfflineDate);
}
}; };
module.exports = { globalSettings, UnitType }; module.exports = { globalSettings, UnitType };

View file

@ -7,6 +7,7 @@ const jBox = require('./../libraries/jBox/jBox.min');
const i18n = require('./../localization'); const i18n = require('./../localization');
const { GUI } = require('./../gui'); const { GUI } = require('./../gui');
const { globalSettings } = require('../globalSettings'); const { globalSettings } = require('../globalSettings');
const Store = require('electron-store');
var ublox = (function () { var ublox = (function () {
@ -181,9 +182,16 @@ var ublox = (function () {
console.log(url); console.log(url);
function processOfflineData(data) { function processOfflineData(data) {
assistnowOffline = splitUbloxData(data); if(globalSettings.assistnowOfflineData == null || ((Date.now() / 1000)-globalSettings.assistnowOfflineDate) > (60*60*24*3)) {
console.log("Assitnow offline commands:" + assistnowOffline.length); console.log("AssistnowOfflineData older than 3 days, refreshing.");
callback(assistnowOffline); globalSettings.assistnowOfflineData = splitUbloxData(data);
globalSettings.assistnowOfflineDate = Math.floor(Date.now() / 1000);
globalSettings.saveAssistnowData();
} else {
console.log("AssitnowOfflineData newer than 3 days. Re-using.");
}
console.log("Assitnow offline commands:" + globalSettings.assistnowOfflineData.length);
callback(globalSettings.assistnowOfflineData);
} }
getBinaryData(url, processOfflineData, loadError); getBinaryData(url, processOfflineData, loadError);