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

ensure only one history database context #3068

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

brindy
Copy link
Contributor

@brindy brindy commented Jul 11, 2024

Task/Issue URL: https://app.asana.com/0/392891325557410/1207755453158856/f
Tech Design URL:
CC:

Description:
Ensures there's only 1 database context for the history store to avoid having merge conflicts.

Steps to test this PR:

Fire button:

  1. Make sure feature is enabled
  2. Visit some sites and generate history
  3. Check history appears
  4. Use the fire button
  5. Check history has been deleted

Settings:
2. Visit some sites and generate history.
3. Disable the autocomplete setting
4. Check history not visible and visit different sites
6. Enable the autocomplete setting
7. Check previous history not visible
8. Repeat but by turning off the recently visited sites setting

Autoclear:

  1. Turn on autoclear and set timer to 5 seconds in the code
  2. Visit some sites
  3. Background the app and trigger autoclear
  4. Check sites not in history
  5. Visit more sites
  6. Kill the app
  7. Check sites not in history

@brindy brindy requested a review from bwaresiak July 11, 2024 13:57
Comment on lines +30 to +32
func isHistoryFeatureEnabled() -> Bool
var isEnabledByUser: Bool { get }
func removeAllHistory() async
Copy link
Contributor Author

Choose a reason for hiding this comment

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

protocol was not in use widely so added these functions which are used and made all dependents use the protocol

@@ -106,25 +103,12 @@ public class HistoryManager: HistoryManaging {

public func removeAllHistory() async {
await withCheckedContinuation { continuation in
historyCoordinator.burnAll {
dbCoordinator.burnAll {
Copy link
Contributor Author

@brindy brindy Jul 11, 2024

Choose a reason for hiding this comment

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

Always use the db coordinator when burning, even if disabled in settings.

extension HistoryManager {

/// Should only be called once in the app
public static func make(isAutocompleteEnabledByUser: @autoclosure @escaping () -> Bool,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved creation logic here. These auto closures mean I don't need to pass in AppSettings into a Core class.

} else {
self.presentPreemptiveCrashAlert()
}
return NullHistoryManager()
Copy link
Contributor Author

@brindy brindy Jul 11, 2024

Choose a reason for hiding this comment

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

Will never actually get used because the app will get killed, but gotta return something for the compiler.

Copy link
Collaborator

@bwaresiak bwaresiak left a comment

Choose a reason for hiding this comment

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

There is some linter error, but its minor.

I also think we could limit the work we do on startup (or move it off main thread in some cases) but I've perf-tested this with 5k visits on the device and it still performed well, so I'm not that concerned.

Great job :)

@brindy brindy merged commit 7dd2411 into release/7.128.0 Jul 12, 2024
14 checks passed
@brindy brindy deleted the brindy/fix-history-not-cleared branch July 12, 2024 10:09
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