mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 01:35:28 +03:00
Fix sponsor loading (#4250)
This commit is contained in:
parent
b84559a48e
commit
82021fd9de
5 changed files with 35 additions and 32 deletions
|
@ -1,12 +1,12 @@
|
||||||
import BuildApi from './BuildApi';
|
import BuildApi from './BuildApi';
|
||||||
import DarkTheme from './DarkTheme';
|
import DarkTheme from './DarkTheme';
|
||||||
|
import GUI from './gui';
|
||||||
import { ispConnected } from './utils/connection';
|
import { ispConnected } from './utils/connection';
|
||||||
|
|
||||||
export default class Sponsor {
|
export default class Sponsor {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this._api = new BuildApi();
|
this._api = new BuildApi();
|
||||||
this._timer = ispConnected() ? setInterval(() => { this.Refresh(); }, 30000) : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Refresh() {
|
Refresh() {
|
||||||
|
@ -18,8 +18,7 @@ export default class Sponsor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._api.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light', this._name,
|
this._api.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light', this._name, (content) => {
|
||||||
(content) => {
|
|
||||||
if (content) {
|
if (content) {
|
||||||
this._div.fadeOut(500, () => {
|
this._div.fadeOut(500, () => {
|
||||||
this._div.html(content);
|
this._div.html(content);
|
||||||
|
@ -29,13 +28,13 @@ export default class Sponsor {
|
||||||
} else {
|
} else {
|
||||||
this._div.hide();
|
this._div.hide();
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSponsorTile(name, div) {
|
loadSponsorTile(name, div) {
|
||||||
this._name = name;
|
this._name = name;
|
||||||
this._div = div;
|
this._div = div;
|
||||||
this.Refresh();
|
|
||||||
|
GUI.interval_add("sponsor", () => { this.Refresh(); }, 15000, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,10 @@ class GuiControl {
|
||||||
interval_add(name, code, interval, first) {
|
interval_add(name, code, interval, first) {
|
||||||
const data = { 'name': name, 'timer': null, 'code': code, 'interval': interval, 'fired': 0, 'paused': false };
|
const data = { 'name': name, 'timer': null, 'code': code, 'interval': interval, 'fired': 0, 'paused': false };
|
||||||
|
|
||||||
|
if (this.interval_array.find((element) => element.name === name)) {
|
||||||
|
this.interval_remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (first === true) {
|
if (first === true) {
|
||||||
code(); // execute code
|
code(); // execute code
|
||||||
|
|
||||||
|
|
|
@ -132,8 +132,20 @@ function startProcess() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('div.open_firmware_flasher a.flash').on('click', function () {
|
||||||
|
if ($('div#flashbutton a.flash_state').hasClass('active') && $('div#flashbutton a.flash').hasClass('active')) {
|
||||||
|
$('div#flashbutton a.flash_state').removeClass('active');
|
||||||
|
$('div#flashbutton a.flash').removeClass('active');
|
||||||
|
$('#tabs ul.mode-disconnected .tab_landing a').click();
|
||||||
|
} else {
|
||||||
|
$('#tabs ul.mode-disconnected .tab_firmware_flasher a').click();
|
||||||
|
$('div#flashbutton a.flash_state').addClass('active');
|
||||||
|
$('div#flashbutton a.flash').addClass('active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const ui_tabs = $('#tabs > ul');
|
const ui_tabs = $('#tabs > ul');
|
||||||
$('a', ui_tabs).click(function () {
|
$('a', '#tabs > ul').click(function () {
|
||||||
if ($(this).parent().hasClass('active') === false && !GUI.tab_switch_in_progress) { // only initialize when the tab isn't already active
|
if ($(this).parent().hasClass('active') === false && !GUI.tab_switch_in_progress) { // only initialize when the tab isn't already active
|
||||||
const self = this;
|
const self = this;
|
||||||
const tabClass = $(self).parent().prop('class');
|
const tabClass = $(self).parent().prop('class');
|
||||||
|
@ -157,6 +169,7 @@ function startProcess() {
|
||||||
if (GUI.connected_to || GUI.connecting_to) {
|
if (GUI.connected_to || GUI.connecting_to) {
|
||||||
$('a.connect').click();
|
$('a.connect').click();
|
||||||
}
|
}
|
||||||
|
// this line is required but it triggers opening the firmware flasher tab again
|
||||||
$('div.open_firmware_flasher a.flash').click();
|
$('div.open_firmware_flasher a.flash').click();
|
||||||
} else if (GUI.allowedTabs.indexOf(tab) < 0) {
|
} else if (GUI.allowedTabs.indexOf(tab) < 0) {
|
||||||
gui_log(i18n.getMessage('tabSwitchUpgradeRequired', [tabName]));
|
gui_log(i18n.getMessage('tabSwitchUpgradeRequired', [tabName]));
|
||||||
|
|
|
@ -81,18 +81,6 @@ export function initializeSerialBackend() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('div.open_firmware_flasher a.flash').click(function () {
|
|
||||||
if ($('div#flashbutton a.flash_state').hasClass('active') && $('div#flashbutton a.flash').hasClass('active')) {
|
|
||||||
$('div#flashbutton a.flash_state').removeClass('active');
|
|
||||||
$('div#flashbutton a.flash').removeClass('active');
|
|
||||||
$('#tabs ul.mode-disconnected .tab_landing a').click();
|
|
||||||
} else {
|
|
||||||
$('#tabs ul.mode-disconnected .tab_firmware_flasher a').click();
|
|
||||||
$('div#flashbutton a.flash_state').addClass('active');
|
|
||||||
$('div#flashbutton a.flash').addClass('active');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
PortHandler.initialize();
|
PortHandler.initialize();
|
||||||
PortUsage.initialize();
|
PortUsage.initialize();
|
||||||
}
|
}
|
||||||
|
@ -155,10 +143,6 @@ function connectDisconnect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ($('div#flashbutton a.flash_state').hasClass('active') && $('div#flashbutton a.flash').hasClass('active')) {
|
|
||||||
$('div#flashbutton a.flash_state').removeClass('active');
|
|
||||||
$('div#flashbutton a.flash').removeClass('active');
|
|
||||||
}
|
|
||||||
GUI.timeout_kill_all();
|
GUI.timeout_kill_all();
|
||||||
GUI.interval_kill_all();
|
GUI.interval_kill_all();
|
||||||
GUI.tab_switch_cleanup(() => GUI.tab_switch_in_progress = false);
|
GUI.tab_switch_cleanup(() => GUI.tab_switch_in_progress = false);
|
||||||
|
|
|
@ -623,6 +623,7 @@ firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.isFlashing = false;
|
self.isFlashing = false;
|
||||||
|
GUI.interval_resume('sponsor');
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = getConfig('erase_chip');
|
let result = getConfig('erase_chip');
|
||||||
|
@ -987,6 +988,7 @@ firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
$('a.flash_firmware').on('click', function () {
|
$('a.flash_firmware').on('click', function () {
|
||||||
self.isFlashing = true;
|
self.isFlashing = true;
|
||||||
|
GUI.interval_pause("sponsor");
|
||||||
const isFlashOnConnect = $('input.flash_on_connect').is(':checked');
|
const isFlashOnConnect = $('input.flash_on_connect').is(':checked');
|
||||||
|
|
||||||
self.enableFlashButton(false);
|
self.enableFlashButton(false);
|
||||||
|
@ -1135,6 +1137,7 @@ firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.buildApi.loadTargets(() => {
|
self.buildApi.loadTargets(() => {
|
||||||
|
console.log('Targets loaded');
|
||||||
$('#content').load("./tabs/firmware_flasher.html", onDocumentLoad);
|
$('#content').load("./tabs/firmware_flasher.html", onDocumentLoad);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue