-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
So far I really like this, it's inspired me to use |
…ion through the history stack
Co-authored-by: Sam Symons <sam@samsymons.com>
Thanks @samsymons! Very good points, did all of them. |
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 😀
There was a problem hiding this comment.
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! { |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! :)
11e9d63
to
4060c15
Compare
4060c15
to
9edc9bb
Compare
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 |
# 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
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
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:
Logging.swift
and sethistoryLoggingEnabled
to trueTest case 1
Test case 2
Test case 3
Test case 4
Internal references:
Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM