mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 00:35:26 +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 DarkTheme from './DarkTheme';
|
||||
import GUI from './gui';
|
||||
import { ispConnected } from './utils/connection';
|
||||
|
||||
export default class Sponsor {
|
||||
|
||||
constructor () {
|
||||
this._api = new BuildApi();
|
||||
this._timer = ispConnected() ? setInterval(() => { this.Refresh(); }, 30000) : null;
|
||||
}
|
||||
|
||||
Refresh() {
|
||||
|
@ -18,24 +18,23 @@ export default class Sponsor {
|
|||
return;
|
||||
}
|
||||
|
||||
this._api.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light', this._name,
|
||||
(content) => {
|
||||
if (content) {
|
||||
this._div.fadeOut(500, () => {
|
||||
this._div.html(content);
|
||||
this._div.fadeIn(500);
|
||||
});
|
||||
this._div.show();
|
||||
} else {
|
||||
this._div.hide();
|
||||
}
|
||||
},
|
||||
);
|
||||
this._api.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light', this._name, (content) => {
|
||||
if (content) {
|
||||
this._div.fadeOut(500, () => {
|
||||
this._div.html(content);
|
||||
this._div.fadeIn(500);
|
||||
});
|
||||
this._div.show();
|
||||
} else {
|
||||
this._div.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadSponsorTile(name, div) {
|
||||
this._name = name;
|
||||
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) {
|
||||
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) {
|
||||
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');
|
||||
$('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
|
||||
const self = this;
|
||||
const tabClass = $(self).parent().prop('class');
|
||||
|
@ -157,6 +169,7 @@ function startProcess() {
|
|||
if (GUI.connected_to || GUI.connecting_to) {
|
||||
$('a.connect').click();
|
||||
}
|
||||
// this line is required but it triggers opening the firmware flasher tab again
|
||||
$('div.open_firmware_flasher a.flash').click();
|
||||
} else if (GUI.allowedTabs.indexOf(tab) < 0) {
|
||||
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();
|
||||
PortUsage.initialize();
|
||||
}
|
||||
|
@ -155,10 +143,6 @@ function connectDisconnect() {
|
|||
}
|
||||
|
||||
} 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.interval_kill_all();
|
||||
GUI.tab_switch_cleanup(() => GUI.tab_switch_in_progress = false);
|
||||
|
|
|
@ -623,6 +623,7 @@ firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
|
||||
self.isFlashing = false;
|
||||
GUI.interval_resume('sponsor');
|
||||
}
|
||||
|
||||
let result = getConfig('erase_chip');
|
||||
|
@ -987,6 +988,7 @@ firmware_flasher.initialize = function (callback) {
|
|||
|
||||
$('a.flash_firmware').on('click', function () {
|
||||
self.isFlashing = true;
|
||||
GUI.interval_pause("sponsor");
|
||||
const isFlashOnConnect = $('input.flash_on_connect').is(':checked');
|
||||
|
||||
self.enableFlashButton(false);
|
||||
|
@ -1135,6 +1137,7 @@ firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
|
||||
self.buildApi.loadTargets(() => {
|
||||
console.log('Targets loaded');
|
||||
$('#content').load("./tabs/firmware_flasher.html", onDocumentLoad);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue