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

History Storage - Please do not merge #108

Merged
merged 16 commits into from
May 24, 2021
Merged

Conversation

tomasstrba
Copy link
Contributor

@tomasstrba tomasstrba commented May 5, 2021

Task/Issue URL: https://app.asana.com/0/72649045549333/1194460468534281/f
Tech Design URL: https://app.asana.com/0/481882893211075/1200247680782234/f
CC:

Description:
As a first part of the project, I’ve implemented a storage of the history. It’s a bit tricky to verify if the implementation is correct, but I tried to help.

Steps to test this PR:

  1. Open Xcode, go to Logging.swift and set historyLoggingEnabled to true
  2. Put '[History]’ into your console filter

Test case 1

  1. Start the browser
  2. Make sure logs contains "History cleaned and loaded successfully. On main thread: no"

Test case 2

  1. Visit duckduckgo.com
  2. Make sure log contains information that http://duckduckgo.com/ and https://duckduckgo.com/ were visited
  3. Make sure log contains information that the title of https://duckduckgo.com/ was updated and the number of visits is still 1.

Test case 3

  1. Visit your fireproof website
  2. Click on the burn button
  3. Make sure log contains information that cleaning was performed. (Fireproof websites aren’t cleaned and will be reloaded as a part of history again)

Test case 4

  1. Play with the browser and look into the log to check whether websites you visited are stored

Internal references:

Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM

@samsymons samsymons self-assigned this May 5, 2021
@samsymons
Copy link
Collaborator

So far I really like this, it's inspired me to use Future more often. 😄 Added some notes on time calculation, and a question about how we plan to store history data. Nothing really blocking this right now, I'll likely approve this after the last bits of feedback are discussed. Amazing work @tomasstrba, your PRs are always a pleasure to review. 👏

@tomasstrba
Copy link
Contributor Author

Thanks @samsymons! Very good points, did all of them.

Copy link
Collaborator

@samsymons samsymons left a comment

Choose a reason for hiding this comment

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

Nice, this is looking great! 🥳

do {
try self.context.save()
} catch {
promise(.failure(HistoryStoreError.savingFailed))
Copy link
Collaborator

Choose a reason for hiding this comment

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

it seems return has been lost here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it’s not necessary because the Future can only succeed or fail once, but it’s a good practice to put it there to avoid a bug in the future. Thanks

entry.addVisit()

historyDictionary[url] = entry
self?.historyDictionary = historyDictionary
Copy link
Collaborator

Choose a reason for hiding this comment

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

just in terms of my beloved micro-optimisations I'd say self?.historyDictionary?[url, default: .init(url: url)].addVisit() ?? { os_log..; return }(), but never mind, just thinking out loudly 😀

Copy link
Contributor Author

@tomasstrba tomasstrba May 11, 2021

Choose a reason for hiding this comment

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

:D I’ll keep your suggestion and use it when max-lines warning appears. Also it’s fine not to have optional for .makeHistory(from:). But thanks, I refreshed the default parameter for dictionaries :)


fileprivate extension Date {

static var weekAgo: Date! {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we move these Date extensions into a separate DateExtensions file as I would expect these to be useful in other places like download history cleanup, etc..

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, good point 👍

webView.goForward()
loginDetectionService?.handle(navigationEvent: .userAction)
}

func goBack() {
shouldStoreNextVisit = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tomasstrba It seems to me here may be a potential issue of not storing a history visit when going back and then opening another url (or link), seems like a common scenario e.g. for the SERP. Is this intentional or should the backForwardList be checked instead?

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 think the use case you described should be fine. When goBack is called, shouldStoreNextVisit is set to false. Then webview displays previous website and updates its url. That triggers adding url into the history - specifically addVisit(of url: URL). The visit is ignored because of the shouldStoreNextVisit flag is false and it's rewritten to true. The next navigation triggers another addVisit(of url: URL) which calls historyCoordinating.addVisit(of: url).

Or am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I got it 🙂 Maybe add this as a comment just for clearance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! :)

@tomasstrba tomasstrba force-pushed the feature/tom/history-storage branch from 11e9d63 to 4060c15 Compare May 11, 2021 11:37
@tomasstrba tomasstrba force-pushed the feature/tom/history-storage branch from 4060c15 to 9edc9bb Compare May 11, 2021 11:38
@tomasstrba
Copy link
Contributor Author

Thanks @samsymons and @mallexxx for your suggestions! I’ll merge this right before the merge of suggestions to avoid a possible Core Data migration if something changes during the second part of my project

@tomasstrba tomasstrba changed the title History Storage History Storage - Please do not merge May 11, 2021
@tomasstrba tomasstrba merged commit c694430 into develop May 24, 2021
@tomasstrba tomasstrba deleted the feature/tom/history-storage branch May 24, 2021 14:59
samsymons added a commit that referenced this pull request May 26, 2021
# By Tomas Strba (4) and others
# Via GitHub
* develop:
  Update the Chrome user agent (#122)
  TabViewModel released immediately from TabCollectionViewModel after its tab is closed (#118)
  User agent updated (#117)
  History Storage - Please do not merge (#108)
  use the temporary unprotected sites list and update the frequency to 30 minutes (#114)
  update email autofill (#113)
  Version 0.6.16
  Force the content blocking rules publisher onto the main thread. (#112)
  Update to BrowserServicesKit 1.1.1 (#111)
  Zoom menu items; Menu Items validation (#105)
  check file headers programatically (#110)
  Fixed up filenames in file headers (#109)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	DuckDuckGo/Bookmarks/Services/Bookmark.xcdatamodeld/Bookmark.xcdatamodel/contents
#	Unit Tests/Bookmarks/Services/LocalBookmarkStoreTests.swift
#	Unit Tests/FileSystem/CoreDataEncryptionTests.swift
samsymons pushed a commit that referenced this pull request May 25, 2023
Task/Issue URL: https://app.asana.com/0/1203137811378537/1204667932873181/f
CC: @samsymons

Description:

Follow-for to Restore the Developer ID script #103
Set Deploy location for Developer ID build to /Applications/DEBUG
Added extra NetP Debug menu items to uninstall SysEx/Login Items
Moved NetP debug menu items handling methods to AppDelegate to allow their usage when no windows are open
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.

4 participants