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

Tab swiping: Feature flag cache #5323

Merged
merged 7 commits into from
Dec 20, 2024

Conversation

0nko
Copy link
Member

@0nko 0nko commented Nov 27, 2024

Task/Issue URL: https://app.asana.com/0/1207418217763355/1208852760335259/f

Description

This PR just caches the feature flag value.

I’ve set the scope of the IsSwipingTabsFeatureEnabled to AppScope because it’s used inside the TabManager, which is used across 2 different activities (BrowserActivity and TabSwitcherActivity).

Steps to test this PR

Testing optional.

@0nko 0nko requested a review from malmstein November 27, 2024 00:03
class IsSwipingTabsFeatureEnabled @Inject constructor(
swipingTabsFeature: SwipingTabsFeature,
) {
private val isEnabled: Boolean = swipingTabsFeature.self().isEnabled()
Copy link
Collaborator

@aitorvs aitorvs Dec 3, 2024

Choose a reason for hiding this comment

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

are you sure this doens't call IO right when the class is instantiated? If it does (I think it does) we should change it.
Also, I would question why do you need this class anyway, you can more easily do the same (without the overhead of a whole new class) by using lazy in the caller (RealTabManager)

nit: also about the invoke() pattern, we don't use it very often and I think we should not use it. it's in general more difficult to get around when working with the IDE

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

@0nko 0nko Dec 4, 2024

Choose a reason for hiding this comment

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

are you sure this doens't call IO right when the class is instantiated? If it does (I think it does) we should change it.

You mean when the SwipingTabsFeature is being initialized for the first time? I don’t think so, at least from what I saw when stepping through the code. But I couldn’t peek inside the generated store so I may be wrong. We can initialize the variable lazily, though, to be safe.

Also, I would question why do you need this class anyway, you can more easily do the same (without the overhead of a whole new class) by using lazy in the caller (RealTabManager)

I’m checking for the flag in multiple places (not here but in a subsequent PR), so I need to store the value somewhere for consistency.

@0nko 0nko requested a review from aitorvs December 4, 2024 18:40
@0nko 0nko merged commit c2c0743 into feature/ondrej/swiping-tabs Dec 20, 2024
4 checks passed
@0nko 0nko deleted the feature/ondrej/tab-swiping-ff-cache branch December 20, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants