Skip to content

Commit

Permalink
Use positive-driven condition for always negated flag
Browse files Browse the repository at this point in the history
Summary: We always negate the result of `isDisabled` method this makes it a bit hard to reason about "is not disabled" statement

Reviewed By: astreet

Differential Revision: D16711168

fbshipit-source-id: 59af3814773ef0b25ef614778135372c4992b090
  • Loading branch information
colriot authored and facebook-github-bot committed Aug 14, 2019
1 parent def8353 commit 3b0cb7e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ public static ComponentContext withComponentScope(ComponentContext context, Comp
* you require that incremental mount is enabled (e.g. you use visibility callbacks). This is
* static to avoid polluting the ComponentContext API.
*/
public static boolean isIncrementalMountDisabled(ComponentContext c) {
return c.mComponentTree != null && !c.mComponentTree.isIncrementalMountEnabled();
public static boolean isIncrementalMountEnabled(ComponentContext c) {
return c.mComponentTree == null || c.mComponentTree.isIncrementalMountEnabled();
}

boolean wasLayoutCanceled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5366,7 +5366,7 @@ public void testIncrementalMountDisabledWhenParentIncrementalMountIsDisabled() {
.incrementalMount(false)
.build();

assertThat(ComponentContext.isIncrementalMountDisabled(parent.getContext())).isTrue();
assertThat(ComponentContext.isIncrementalMountEnabled(parent.getContext())).isFalse();

final RecyclerBinder recyclerBinder =
new RecyclerBinder.Builder()
Expand Down Expand Up @@ -5394,7 +5394,7 @@ public void testIncrementalMountEnabledWhenParentIncrementalMountIsEnabled() {
.incrementalMount(true)
.build();

assertThat(ComponentContext.isIncrementalMountDisabled(parent.getContext())).isFalse();
assertThat(ComponentContext.isIncrementalMountEnabled(parent.getContext())).isTrue();

final RecyclerBinder recyclerBinder =
new RecyclerBinder.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public RecyclerBinder build(ComponentContext c) {

// Incremental mount will not work if this ComponentTree is nested in a parent with it turned
// off, so always disable it in that case
incrementalMount = incrementalMount && !ComponentContext.isIncrementalMountDisabled(c);
incrementalMount = incrementalMount && ComponentContext.isIncrementalMountEnabled(c);

if (layoutInfo == null) {
layoutInfo = new LinearLayoutInfo(c.getAndroidContext(), VERTICAL, false);
Expand Down

0 comments on commit 3b0cb7e

Please sign in to comment.