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

Adding dark and light theme names to the sponsor request (params to API) (#3561)

* Adding dark and light theme names to the sponsor request (params to API)

* Renamed configEnabled to configSetting as it does not reflect whether or not the darkTheme is currently enabled (just its setting).

* Missed the configEnabled in the optionsTab.
This commit is contained in:
J Blackman 2023-09-27 22:20:26 +10:00 committed by GitHub
parent 56ab8073dc
commit e120c4893f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 11 deletions

View file

@ -172,8 +172,8 @@ export default class BuildApi {
this.load(url, onSuccess, onFailure); this.load(url, onSuccess, onFailure);
} }
loadSponsorTile(onSuccess, onFailure) { loadSponsorTile(mode, onSuccess, onFailure) {
const url = `${this._url}/api/configurator/sponsors`; const url = `${this._url}/api/configurator/sponsors/${mode}`;
this.load(url, onSuccess, onFailure); this.load(url, onSuccess, onFailure);
} }
} }

View file

@ -8,13 +8,14 @@ const css_dark = [
]; ];
const DarkTheme = { const DarkTheme = {
configEnabled: undefined, configSetting: undefined,
enabled: false,
}; };
DarkTheme.isDarkThemeEnabled = function (callback) { DarkTheme.isDarkThemeEnabled = function (callback) {
if (this.configEnabled === 0) { if (this.configSetting === 0) {
callback(true); callback(true);
} else if (this.configEnabled === 2) { } else if (this.configSetting === 2) {
if (GUI.isCordova()) { if (GUI.isCordova()) {
cordova.plugins.ThemeDetection.isDarkModeEnabled(function(success) { cordova.plugins.ThemeDetection.isDarkModeEnabled(function(success) {
callback(success.value); callback(success.value);
@ -47,27 +48,28 @@ DarkTheme.apply = function() {
}; };
DarkTheme.autoSet = function() { DarkTheme.autoSet = function() {
if (this.configEnabled === 2) { if (this.configSetting === 2) {
this.apply(); this.apply();
} }
}; };
DarkTheme.setConfig = function (result) { DarkTheme.setConfig = function (result) {
if (this.configEnabled !== result) { if (this.configSetting !== result) {
this.configEnabled = result; this.configSetting = result;
this.apply(); this.apply();
} }
}; };
DarkTheme.applyDark = function () { DarkTheme.applyDark = function () {
css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', false)); css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', false));
this.enabled = true;
}; };
DarkTheme.applyNormal = function () { DarkTheme.applyNormal = function () {
css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', true)); css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', true));
this.enabled = false;
}; };
export function setDarkTheme(enabled) { export function setDarkTheme(enabled) {
DarkTheme.setConfig(enabled); DarkTheme.setConfig(enabled);

View file

@ -19,6 +19,7 @@ import { gui_log } from '../gui_log';
import semver from 'semver'; import semver from 'semver';
import { checkChromeRuntimeError, urlExists } from '../utils/common'; import { checkChromeRuntimeError, urlExists } from '../utils/common';
import { generateFilename } from '../utils/generate_filename'; import { generateFilename } from '../utils/generate_filename';
import DarkTheme from '../DarkTheme';
const firmware_flasher = { const firmware_flasher = {
targets: null, targets: null,
@ -55,7 +56,7 @@ firmware_flasher.initialize = function (callback) {
return; return;
} }
self.releaseLoader.loadSponsorTile( self.releaseLoader.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light',
(content) => { (content) => {
if (content) { if (content) {
$('div.tab_sponsor').html(content); $('div.tab_sponsor').html(content);

View file

@ -179,7 +179,7 @@ options.initCordovaForceComputerUI = function () {
options.initDarkTheme = function () { options.initDarkTheme = function () {
$('#darkThemeSelect') $('#darkThemeSelect')
.val(DarkTheme.configEnabled) .val(DarkTheme.configSetting)
.change(function () { .change(function () {
const value = parseInt($(this).val()); const value = parseInt($(this).val());