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

refactor(core): read tray icon only on desktop, refactor Context #6719

Merged
merged 5 commits into from
Apr 19, 2023

Conversation

lucasfernog
Copy link
Member

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

@lucasfernog lucasfernog requested a review from a team as a code owner April 16, 2023 15:01
Copy link
Member

@chippers chippers left a comment

Choose a reason for hiding this comment

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

There's 2 naming convention requests and 1 security-borderline issue. The is_ naming convention is a take it or leave it, but I think the with_ one is confusing.

Definitely fix the Default scope open regex however.

On a more of a "comment" note, we should probably decide on an architectural way to prevent so many cfgs mixed in with application logic. My first item to reach to would be to refactor concepts into Structs/Enums and use cfg inside those items to make them noops on cfg'd out platforms. Then the flow of stuff isn't broken up by cfg items all the time. This can apply to both the codebase and the codegen codebase.

Comment on lines 129 to 135
fn mobile(&self) -> bool {
matches!(self, Target::Android | Target::Ios)
}

fn desktop(&self) -> bool {
!self.mobile()
}
Copy link
Member

Choose a reason for hiding this comment

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

Not 100% sure we've been following this convention throughout the codebase, but since these aren't returning a "field" on the item but a property of it we may want to use the is_ prefix.

Suggested change
fn mobile(&self) -> bool {
matches!(self, Target::Android | Target::Ios)
}
fn desktop(&self) -> bool {
!self.mobile()
}
fn is_mobile(&self) -> bool {
matches!(self, Target::Android | Target::Ios)
}
fn is_desktop(&self) -> bool {
!self.mobile()
}

@@ -58,7 +58,7 @@ impl From<Vec<String>> for ExecuteArgs {
}

/// Shell scope configuration.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
Copy link
Member

Choose a reason for hiding this comment

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

This derive will have the open field set to None by default, which means that it is not matched through the default regex. It should probably match the default of ^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+. We may want to adjust how we create it from the config so that we don't need to have the "default" filtering regex in more than 1 place, to reduce future duplication mistakes.

Comment on lines 688 to 695
pub fn with_system_tray_icon(&mut self, icon: Icon) {
self.system_tray_icon.replace(icon);
}

/// Sets the app shell scope.
#[cfg(shell_scope)]
#[inline(always)]
pub fn with_shell_scope(&mut self, scope: scope::ShellScopeConfig) {
Copy link
Member

Choose a reason for hiding this comment

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

with_ prefixed methods are typically used for alternative constructors, not replacements of a single field. If there is a self being passed to a with_ function, then it's probably named wrong. I think set_ in this case works best since it's completely replacing a single item.

Suggested change
pub fn with_system_tray_icon(&mut self, icon: Icon) {
self.system_tray_icon.replace(icon);
}
/// Sets the app shell scope.
#[cfg(shell_scope)]
#[inline(always)]
pub fn with_shell_scope(&mut self, scope: scope::ShellScopeConfig) {
pub fn set_system_tray_icon(&mut self, icon: Icon) {
self.system_tray_icon.replace(icon);
}
/// Sets the app shell scope.
#[cfg(shell_scope)]
#[inline(always)]
pub fn set_shell_scope(&mut self, scope: scope::ShellScopeConfig) {

@lucasfernog lucasfernog merged commit ae10298 into next Apr 19, 2023
@lucasfernog lucasfernog deleted the refactor/context-tray-icon branch April 19, 2023 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants