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

Add RC flag for storing history #4495

Conversation

CrisBarreiro
Copy link
Contributor

@CrisBarreiro CrisBarreiro commented May 2, 2024

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

Description

Add RC flag for storing history

Steps to test this PR

Feature 1

  • Create a JSON blob with history-> storeHistory enabled
  • Visit a site
  • Use flipper or database inspector to check site has been stored in the database, and shown in suggestions

Feature 2

  • Create a JSON blob with history-> storeHistory enabled
  • Open private search settings
  • Toggle off visited sites
  • Visit a site
  • Use flipper or database inspector to check site has not been stored in the database, and no suggestions are shown (even for sites previously visited)
  • Toggle on visited sites again
  • Visit a site
  • Use flipper or database inspector to check site has been stored in the database, and suggestions are shown

Feature 2

  • Create a JSON blob with history-> storeHistory disabled
  • Visit a site
  • Use flipper or database inspector to check site has not been stored in the database, and no suggestions are shown (even for sites previously visited)
  • Open private search settings
  • Check visited sites option is not visible

UI changes

rc_disabled
rc_enabled
image

@CrisBarreiro CrisBarreiro marked this pull request as ready for review May 2, 2024 12:40
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch 2 times, most recently from 132f86f to 28322ab Compare May 3, 2024 15:01
@CrisBarreiro CrisBarreiro changed the base branch from feature/cbarreiro/autocomplete/clear-on-fire-button to feature/cbarreiro/autocomplete/delete-old-items May 3, 2024 15:03
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch 2 times, most recently from a311445 to 1c7f509 Compare May 6, 2024 10:15
Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

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

I'm taking a pass through all PRs, leaving some comments on this one. Just minor comments, overall looks good!


package com.duckduckgo.history.api

interface HistoryRCWrapper {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this one in the :api module? Seems only used internally

@@ -90,6 +95,14 @@ class RealHistoryRepository(
}
}

override fun isHistoryUserEnabled(default: Boolean): Boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need default here? could that detail be moved into SharedPreferencesHistoryDataStore impl instead? I assume you need that value to change based on RC flag, if so maybe we can just have it as dependency there.

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, I need the value to change based on the RC flag (If the local value is null, then default to the RC flag value). The reason I added it there is because I'm considering handling that case as part of the business logic. Let me know what you think

@@ -57,4 +62,16 @@ class RealNavigationHistory @Inject constructor(
override suspend fun clearOldEntries() {
historyRepository.clearEntriesOlderThan(currentTimeProvider.localDateTimeNow().minusDays(30))
}

override fun isHistoryUserEnabled(): Boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if all these methods that are related to toggle should be part of HistoryFeature (aka. RealHistoryRCWrapper). So we have repository for storing and dealing with urls, and HistoryFeature for feature state (including user preference)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, any feature dealing with history would need access to these methods, so the cleanest the API we give them, the better, IMO. Also, I think that would be a bit confusing, since, as I mentioned on my previous comment, we usually reserve the *Feature suffix for RC-related stuff. Also note that this method is related to user settings, not RC

/**
* Returns whether the history RC flag is enabled.
*/
fun isHistoryRCFlagEnabled(): Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

What about naming it as isHistoryUserVisible? just nit to name it based on what we expect rather than what we internally check.

Copy link
Contributor Author

@CrisBarreiro CrisBarreiro May 6, 2024

Choose a reason for hiding this comment

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

I'd rather change it to isHistoryFeatureAvailable, userVisible sounds too close to the UI layer for an API method

@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from 1f369f9 to bdc61b8 Compare May 6, 2024 16:44
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from 9cbb477 to c0a8b79 Compare May 15, 2024 14:09
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from bdc61b8 to a59c675 Compare May 15, 2024 14:09
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from c0a8b79 to 8d3eaca Compare May 15, 2024 15:52
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from 0f2046a to 5d17569 Compare May 15, 2024 15:52
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from 8d3eaca to a7e5ea0 Compare May 16, 2024 10:16
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from 5d17569 to 997ab03 Compare May 16, 2024 10:16
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from a7e5ea0 to 381d765 Compare May 22, 2024 08:45
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from 997ab03 to 2b54b39 Compare May 22, 2024 08:46
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from 381d765 to 6bf6500 Compare May 22, 2024 09:12
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from 2b54b39 to 1e05eca Compare May 22, 2024 09:12
@CrisBarreiro CrisBarreiro mentioned this pull request May 22, 2024
3 tasks
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from 6bf6500 to 27d4ca2 Compare May 22, 2024 14:22
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from 1e05eca to f63eb01 Compare May 22, 2024 14:22
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from 27d4ca2 to da291cf Compare May 27, 2024 08:10
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from f63eb01 to c0349ac Compare May 27, 2024 08:10
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/delete-old-items branch from da291cf to c7e0aa5 Compare May 27, 2024 10:00
@CrisBarreiro CrisBarreiro force-pushed the feature/cbarreiro/autocomplete/rc-flag branch from c0349ac to 0490131 Compare May 27, 2024 10:00
Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

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

LGTM

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

### Description
Display an in-app message (above auto-complete results. See
https://app.asana.com/0/0/1206816228247403/f for rules

### Steps to test this PR

Update RC and set `storeHistory` to enabled. Alternatively, update
`shouldStoreHistory` in `RealHistoryWrapper` so it returns true

_Banner is not shown for new users_
- [ ] Do a clean install
- [ ] Perform a search or visit a site
- [ ] Repeat the same query again
- [ ] Check history-based results are shown but no in-app message
appears
- [ ] Complete the onboarding
- [ ] Repeat the same query again 
- [ ] Check history-based results are shown but no in-app message
appears

_Banner is shown for existing users_ 
- [ ] Update from a previous version of the app with completed
onboarding, or update `isExistingUser` in `AutoComplete`so it returns
true and do a clean install
- [ ] Perform a search or visit a site
- [ ] Repeat the same query again
- [ ] Check history-based results are shown but and an in-app message
appears

_Banner isn't shown after being dismissed_
- [ ] Update `isExistingUser` in `AutoComplete`so it returns true and do
a clean install
- [ ] Perform a search or visit a site
- [ ] Repeat the same query again
- [ ] Check history-based results are shown but and an in-app message
appears
- [ ] Close the banner
- [ ] Repeat the same query again
- [ ] Check history-based results are shown but no in-app message
appears

_Banner is not shown when there are no history based-results results_
- [ ] Update `isExistingUser` in `AutoComplete`so it returns true and do
a clean install
- [ ] Visit wikipedia.org and add it to favorites
- [ ] Use fire button
- [ ] Type _wikipedia_
- [ ] Check no history-based results nor the banner are shown

_Banner isn't shown more than 3 times_ 
Update `isExistingUser` in `AutoComplete`so it returns true and do a
clean install
- [ ] Perform a search or visit a site
- [ ] Repeat the same query again
- [ ] Check history-based results are shown but and an in-app message
appears
- [ ] Repeat previous 3 steps 4 times. Check the fourth time, the banner
isn't shown anymore


### UI changes

![banner](https://github.com/duckduckgo/Android/assets/6297834/11f748d9-5131-42a8-a5bc-03330a585180)
@CrisBarreiro CrisBarreiro merged commit fa6922a into feature/cbarreiro/autocomplete/delete-old-items May 29, 2024
4 checks passed
@CrisBarreiro CrisBarreiro deleted the feature/cbarreiro/autocomplete/rc-flag branch May 29, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants