Skip to content

Commit e120c48

Browse files
authored
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.
1 parent 56ab807 commit e120c48

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/js/BuildApi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ export default class BuildApi {
172172
this.load(url, onSuccess, onFailure);
173173
}
174174

175-
loadSponsorTile(onSuccess, onFailure) {
176-
const url = `${this._url}/api/configurator/sponsors`;
175+
loadSponsorTile(mode, onSuccess, onFailure) {
176+
const url = `${this._url}/api/configurator/sponsors/${mode}`;
177177
this.load(url, onSuccess, onFailure);
178178
}
179179
}

src/js/DarkTheme.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ const css_dark = [
88
];
99

1010
const DarkTheme = {
11-
configEnabled: undefined,
11+
configSetting: undefined,
12+
enabled: false,
1213
};
1314

1415
DarkTheme.isDarkThemeEnabled = function (callback) {
15-
if (this.configEnabled === 0) {
16+
if (this.configSetting === 0) {
1617
callback(true);
17-
} else if (this.configEnabled === 2) {
18+
} else if (this.configSetting === 2) {
1819
if (GUI.isCordova()) {
1920
cordova.plugins.ThemeDetection.isDarkModeEnabled(function(success) {
2021
callback(success.value);
@@ -47,27 +48,28 @@ DarkTheme.apply = function() {
4748
};
4849

4950
DarkTheme.autoSet = function() {
50-
if (this.configEnabled === 2) {
51+
if (this.configSetting === 2) {
5152
this.apply();
5253
}
5354
};
5455

5556
DarkTheme.setConfig = function (result) {
56-
if (this.configEnabled !== result) {
57-
this.configEnabled = result;
57+
if (this.configSetting !== result) {
58+
this.configSetting = result;
5859
this.apply();
5960
}
6061
};
6162

6263
DarkTheme.applyDark = function () {
6364
css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', false));
65+
this.enabled = true;
6466
};
6567

6668
DarkTheme.applyNormal = function () {
6769
css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', true));
70+
this.enabled = false;
6871
};
6972

70-
7173
export function setDarkTheme(enabled) {
7274
DarkTheme.setConfig(enabled);
7375

src/js/tabs/firmware_flasher.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { gui_log } from '../gui_log';
1919
import semver from 'semver';
2020
import { checkChromeRuntimeError, urlExists } from '../utils/common';
2121
import { generateFilename } from '../utils/generate_filename';
22+
import DarkTheme from '../DarkTheme';
2223

2324
const firmware_flasher = {
2425
targets: null,
@@ -55,7 +56,7 @@ firmware_flasher.initialize = function (callback) {
5556
return;
5657
}
5758

58-
self.releaseLoader.loadSponsorTile(
59+
self.releaseLoader.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light',
5960
(content) => {
6061
if (content) {
6162
$('div.tab_sponsor').html(content);

src/js/tabs/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ options.initCordovaForceComputerUI = function () {
179179

180180
options.initDarkTheme = function () {
181181
$('#darkThemeSelect')
182-
.val(DarkTheme.configEnabled)
182+
.val(DarkTheme.configSetting)
183183
.change(function () {
184184
const value = parseInt($(this).val());
185185

0 commit comments

Comments
 (0)