Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent false-positive when matching dark themes #24133

Closed
wants to merge 1 commit into from
Closed

Prevent false-positive when matching dark themes #24133

wants to merge 1 commit into from

Conversation

WhyNotHugo
Copy link
Contributor

References: #17061

@CLAassistant
Copy link

CLAassistant commented Mar 2, 2022

CLA assistant check
All committers have signed the CLA.

@WhyNotHugo
Copy link
Contributor Author

Note: I signed a DCO, not a CLA as the bot above indicates.

@@ -499,9 +499,12 @@ std::optional<bool> IsDarkMode() {

result = false;

if (gtkThemePortalString.contains(
if (gtkThemePortalString.endsWith(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in sync with the xesttings part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's better to create a helper function in private namespace? IsGtkDarkTheme or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will do.

Copy link
Contributor

Choose a reason for hiding this comment

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

bool IsGtkDarkTheme(const QString &theme) {
	const auto themeLower = theme.toLower();
	return themeLower.contains(qsl("-dark-")) || themeLower.endsWith(qsl("-dark"));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in private namespace

I'm not very familiar with C++ and I'm not sure about this bit.

@23rd
Copy link
Collaborator

23rd commented Mar 4, 2022

You can squash all commits to the first one. 👌

@WhyNotHugo
Copy link
Contributor Author

Squashed!

@WhyNotHugo
Copy link
Contributor Author

I'm curious, why this:

			if (IsGtkDarkTheme(gtkThemePortalString)) {
				result = true;
				return result;
			}

Instead of:

			if (IsGtkDarkTheme(gtkThemePortalString)) {
				return true;
			}

Also, result = false repeats a lot, but it's not necessary since it only ever changes to true before returning. Would this make more sense?

-	std::optional<bool> result;
+	std::optional<bool> result = false;

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Mar 4, 2022

I'm curious, why this

We're checking all the APIs and return as soon as at least one of them returns dark mode

Also, result = false repeats a lot, but it's not necessary since it only ever changes to true before returning. Would this make more sense?

The default value of result is std::nullopt (what means 'not supported'), not false (what means light mode)

@john-preston
Copy link
Member

@WhyNotHugo what's DCO?

@john-preston
Copy link
Member

@WhyNotHugo I see, Developer Certificate of Origin.

The point of the CLA is to give the submitted work to the public domain so that if I need to do any relicensing in the future I won't need to contact all the people who sent PRs here.

@WhyNotHugo
Copy link
Contributor Author

Hmm, upon further inspection, there's a lot of inconsistency here:

I had missed the discrepancy between title and body the previous time. Isn't it misleading to call it a DCO if the text is entirely different and has different goals?

I'm also a bit confused about the implications here: Telegram is distributed under the GPL, but if all developers have signed this agreement, doesn't that imply that it's fully been released into public domain?

The point of the CLA is to give the submitted work to the public domain so that if I need to do any relicensing in the future I won't need to contact all the people who sent PRs here.

I'm familiar. Using a CLA in this style is quite common for open source projects that later want to turn into a non-open source or non-free project.

@john-preston
Copy link
Member

john-preston commented Mar 5, 2022

@WhyNotHugo Yes, for example I've maintained a closed source version for Telegram Support volunteers, that was later merged into the current open source version. But still I leave a possibility for something like that to happen again. Sorry, it is what it is.

There are no plans to close the source code of any Telegram app (all the apps and the client side libraries for building other apps, like TDLib, are open source and this is not planned to be changed). But still I need the full control of the source code, sorry.

@john-preston
Copy link
Member

Perhaps the phrasing could be improved indeed.

@ilya-fedin
Copy link
Contributor

@WhyNotHugo if you don't agree with the CLA, maybe it's better to close the PR?

@WhyNotHugo
Copy link
Contributor Author

Oh, pretty sure I did accept it, I'll do that again.

@WhyNotHugo
Copy link
Contributor Author

Perhaps the phrasing could be improved indeed.

Including the document in the repo too would probably be good enough, making it a lot less confusing/ambiguous what people agreed to. Especially since the ACTUAL body of the agreement is hosted externally and all references made by the bot are are not quite accurate.

@WhyNotHugo
Copy link
Contributor Author

Oh, can't sign right now since bot is down anyway. Will retry later.

image

@WhyNotHugo
Copy link
Contributor Author

Looks like the CLA bot now needs a few more permissions that are, regrettably, not at all reasonable (e.g.: read-write access to several private and public resources):

image

@ilya-fedin
Copy link
Contributor

So, will you sign?

@vimpostor
Copy link
Contributor

vimpostor commented Apr 11, 2022

Looks like the CLA bot now needs a few more permissions that are, regrettably, not at all reasonable (e.g.: read-write access to several private and public resources):

Maybe try something similar to this: cla-assistant/cla-assistant#243 (comment)
CLA Assistant only needs those permissions if you setup a CLA yourself, these permissions shouldn't come up when you just want to sign one.

@WhyNotHugo
Copy link
Contributor Author

@vimpostor Thanks for the hint. It looks like https://cla-assistant.io/telegramdesktop/tdesktop should work.

I though the CLA Assitant was down again:

image

Apparently not, it loads the body via an XHR call which takes 26 seconds to load:

image

Given that the page loads in under 2 seconds, it never occurred to me that there was an artificial delay of 26 seconds before someone could read the agreement. There's no clue that one has to wait (and I'm curious why that wait is enforced).

For the record, the CLA currently reads:

Telegram Desktop Developer Certificate of Origin

By making a contribution to this project, I certify that:

(a) The contribution was created in whole by me or is based upon previous work that, to the best of my knowledge, is in the public domain and I have the right to put it in the public domain.

(d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all metadata and personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed.

(e) I am granting this work into the public domain.

I do still believe that having the document in-repo would be a simpler and more transparent approach.

@vimpostor
Copy link
Contributor

I do still believe that having the document in-repo would be a simpler and more transparent approach.

I agree but I guess the advantage of the current approach is that Preston can see directly in the PR if someone signed the CLA.

If you put the CLA just in the repo, you would also need to require every contributor to signoff their commit (similar to the Linux Kernel) with Signed-off-by: and you still wouldn't be completely sure that they agreed to the CLA. Also I am not sure if you can apply the DCO Signoff workflow at all to a CLA and still be legally sound.

@WhyNotHugo
Copy link
Contributor Author

Given 17fcc72, this is no longer relevant. Thanks @ilya-fedin for implementing that! 🍻

@WhyNotHugo WhyNotHugo closed this Apr 19, 2022
@WhyNotHugo WhyNotHugo deleted the prevent-dark-mode-false-positives branch April 19, 2022 13:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants