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:
parent
152124627c
commit
a3778ae40f
3 changed files with 21 additions and 3 deletions
|
@ -78,6 +78,7 @@ $(function() {
|
|||
$('a', activeTab).trigger('click');
|
||||
}
|
||||
|
||||
globalSettings.store = store;
|
||||
globalSettings.unitType = store.get('unit_type', UnitType.none);
|
||||
globalSettings.mapProviderType = store.get('map_provider_type', 'osm');
|
||||
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.proxyLayer = store.get('proxylayer', 'your_proxy_layer_name');
|
||||
globalSettings.showProfileParameters = store.get('show_profile_parameters', 1);
|
||||
globalSettings.assistnowOfflineData = store.get('assistnow_offline_data', []);
|
||||
globalSettings.assistnowOfflineDate = store.get('assistnow_offline_date', 0);
|
||||
updateProfilesHighlightColours();
|
||||
|
||||
var cliAutocomplete = store.get('cli_autocomplete', true);
|
||||
|
|
|
@ -22,6 +22,13 @@ var globalSettings = {
|
|||
docsTreeLocation: 'master',
|
||||
cliAutocomplete: true,
|
||||
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 };
|
|
@ -7,6 +7,7 @@ const jBox = require('./../libraries/jBox/jBox.min');
|
|||
const i18n = require('./../localization');
|
||||
const { GUI } = require('./../gui');
|
||||
const { globalSettings } = require('../globalSettings');
|
||||
const Store = require('electron-store');
|
||||
|
||||
|
||||
var ublox = (function () {
|
||||
|
@ -181,9 +182,16 @@ var ublox = (function () {
|
|||
console.log(url);
|
||||
|
||||
function processOfflineData(data) {
|
||||
assistnowOffline = splitUbloxData(data);
|
||||
console.log("Assitnow offline commands:" + assistnowOffline.length);
|
||||
callback(assistnowOffline);
|
||||
if(globalSettings.assistnowOfflineData == null || ((Date.now() / 1000)-globalSettings.assistnowOfflineDate) > (60*60*24*3)) {
|
||||
console.log("AssistnowOfflineData older than 3 days, refreshing.");
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue