1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 00:05:22 +03:00

Merge pull request #1898 from mikeller/fix_unified_target_cacheing

Fixed cache expiry for Unified Target configurations.
This commit is contained in:
Michael Keller 2020-02-27 00:24:13 +13:00 committed by GitHub
commit b4d9099537
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -604,7 +604,8 @@ TABS.firmware_flasher.initialize = function (callback) {
const manufacturerId = manufacturerIds[index];
const targetId = `${target}+${manufacturerId}`;
// Check to see if the cached configuration is the one we want.
if (!storageObj || !storageObj.target || storageObj.target !== targetId) {
if (!storageObj || !storageObj.target || storageObj.target !== targetId
|| !storageObj.lastUpdate || checkTime - storageObj.lastUpdate > expirationPeriod) {
// Have to go and try and get the unified config, and then do stuff
$.get(unifiedConfigBoard[manufacturerId], function(response) {
console.log('got unified config');
@ -612,7 +613,7 @@ TABS.firmware_flasher.initialize = function (callback) {
let tempObj = {};
tempObj['data'] = response;
tempObj['target'] = targetId;
tempObj['checkTime'] = checkTime;
tempObj['lastUpdate'] = checkTime;
let newStorageObj = {};
newStorageObj[storageTag] = tempObj;
chrome.storage.local.set(newStorageObj);