Skip to content

Conversation

@blckmn
Copy link
Member

@blckmn blckmn commented Sep 2, 2023

I couldn't see any way to identify whether or not the dark theme was enabled or not. So added the property to DarkTheme.

If anyway has a better idea please let me know.

@github-actions

This comment has been minimized.

@haslinghuis
Copy link
Member

haslinghuis commented Sep 2, 2023

We have something like:

DarkTheme.isDarkThemeEnabled(function(isEnabled) {
windowWatcherUtil.passValue(createdWindow, 'darkTheme', isEnabled);
});

and

options.initDarkTheme = function () {
$('#darkThemeSelect')
.val(DarkTheme.configEnabled)
.change(function () {
const value = parseInt($(this).val());
setConfig({'darkTheme': value});
setDarkTheme(value);
}).change();
};

@asizon
Copy link
Member

asizon commented Sep 2, 2023

We have something like:

DarkTheme.isDarkThemeEnabled(function(isEnabled) {
windowWatcherUtil.passValue(createdWindow, 'darkTheme', isEnabled);
});

and

options.initDarkTheme = function () {
$('#darkThemeSelect')
.val(DarkTheme.configEnabled)
.change(function () {
const value = parseInt($(this).val());
setConfig({'darkTheme': value});
setDarkTheme(value);
}).change();
};

Yes,i think is better to go with the current available function.

@blckmn
Copy link
Member Author

blckmn commented Sep 2, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> FAIL
  • Tested label found -> FAIL
  • assigned to an approver -> PASS
  • approver count at least three -> FAIL

loadSponsorTile(onSuccess, onFailure) {
const url = `${this._url}/api/configurator/sponsors`;
loadSponsorTile(mode, onSuccess, onFailure) {
const url = `${this._url}/api/configurator/sponsors/${mode}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for window.matchMedia('(prefers-color-scheme: dark)').matches would do

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test this.


const DarkTheme = {
configEnabled: undefined,
enabled: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would duplicate configEnabled

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm not sure it does. It looked to me that configEnabled is not binary, so supports the option 'honour the system' so can't be relied upon for stating that dark theme was in fact enabled.

Copy link
Member

@haslinghuis haslinghuis Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above statement would extract the value or [use] get ConfigStorage darkTheme value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which means configEnabled is not well named. It should be configSetting or similar. It can't be relied upon as to if it's actually applied or not... sure it'll have a value of two... but does that mean dark theme is active? I don't think it does because the test of isEnabled is not persisted...

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.7% 1.7% Duplication

@blckmn
Copy link
Member Author

blckmn commented Sep 2, 2023

We have something like:

DarkTheme.isDarkThemeEnabled(function(isEnabled) {
windowWatcherUtil.passValue(createdWindow, 'darkTheme', isEnabled);
});

if (chrome.app.window !== undefined) {
windowWatcherUtil.passValue(chrome.app.window.get("receiver_msp"), 'darkTheme', isEnabled);
}

I actually don't like this approach. The reason is both receiver.js and darktheme.js are coupled together. It would be better that receiver (and any others) registers its interest (observes) the enabled / disabled aspect of darktheme (and gets a callback when it happens). Then darktheme is entirely standalone... and not coupled to any tabs.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2023

Do you want to test this code? Here you have an automated build:
Betaflight-Configurator-Android
Betaflight-Configurator-Linux
Betaflight-Configurator-macOS
Betaflight-Configurator-Windows
WARNING: It may be unstable and result in corrupted configurations or data loss. Use only for testing!

@haslinghuis
Copy link
Member

Agree, it's part of code from 2020 to fix dark theme on Android.

@blckmn
Copy link
Member Author

blckmn commented Sep 2, 2023

Agree, it's part of code from 2020 to fix dark theme on Android.

I'll clean it up.

@blckmn
Copy link
Member Author

blckmn commented Sep 27, 2023

@haslinghuis @nerdCopter this is good to go as is... I will fix up the call backs separately in another PR

@blckmn blckmn self-assigned this Sep 27, 2023
@blckmn blckmn added this to the 10.10.0 milestone Sep 27, 2023
@haslinghuis haslinghuis merged commit e120c48 into betaflight:master Sep 27, 2023
@blckmn blckmn deleted the sponsors branch September 27, 2023 20:42
chmelevskij pushed a commit to chmelevskij/betaflight-configurator that referenced this pull request Apr 27, 2024
…PI) (betaflight#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: COMPLETED

Development

Successfully merging this pull request may close these issues.

4 participants