-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Exporting/Importing the history #444
base: main
Are you sure you want to change the base?
Conversation
Exporting the history to JSON is fully working, first try! :) I mostly copied what exporting Bookmarks does, which meant I had to add a sealed History class with a Entry data class to WebPage, which caused problems in SuggestionsAdapter's "when (webPage)", which I fixed by adding it also as an (unused) "is History" case, which shouldn't make any problems down the road hopefully. Perhaps it could be cleaned up a little bit, with better names for example. Next step would be to allow importing the history from a backup, a private addHistoryEntry function already exists which I could reuse for this. What has to be decided first is do I just replace the history (after warning the user) or do I offer a choice between replacing it or appending the history to the already existing one (this could be done by exporting both, combining the JSONs and importing that so it's not that important).
I've opened this draft PR so this functionality hopefully gets added to the official version (when finished and thoroughly tested) as I lost a lot of tabs lately because I didn't know about issue #193 and hope to recover at least some of them through the history, additionally this serves to get some feedback, as while this should work without problems I've never worked with Kotlin before so I'm missing the experience for this language. Also I've got a question regarding the importing of the history, should the user be asked if they want to append the history or replace it, or should it just always be replaced (with a warning of course)? Thanks in advance! |
@Cook-I-T Sorry you fell victim of #193. We really ought to fix it at some point.
You should be able to do that without import or export right? Just go to history and open the pages you want, done. You could also save the history page as PDF through the print option and refer to it later.
Not sure why user would want to import history. Apologize if my comments feel dismissive of your contribution. I think it's awesome that you try to solve your issue by going into the code 🥳That's what open source is all about. I'm also not saying I don't want to merge that functionality in one form or another. Just trying to have an open mind about it that's all. So the first step is to put my product architect hat on ask myself do we need that new functionality or is it just going to add more bloat to an already bloated product? 😁 |
Well some of the tabs haven't been loaded in... quite some time so being limited to seeing the last 100 entries in the history is not enough... yeah I really shouldn't have such a backlog of stuff in the first place but that's a bad habit I ain't gonna loose anytime soon XD
Yeah I thought about asking if such a feature would be needed, but then decided not to. My thought behind that was that it would allow users to export their stuff and save it as a backup in case something happens and also allow easy transfer to a new phone. And as there is already a bookmark export and import function I though also allowing to import the history back would make sense. So I'm happy to try to also implement importing the history (by sticking to what importing bookmarks does once I figure out how to create dialog boxes) as I'd say it's useful enough to warrant it's inclusion. |
How do you export more than the last 100 entries? Can you tap in the actual WebView history? |
Not sure what you mean by that. You know you can backup your sessions right? |
Sorry mistyped I meant history not tabs, changed it. That's what I would've done regularly if I had known of #193 XD
I get the history directly from the database it gets written to, using a copy of (the seemingly unused) getAllHistoryEntries() function which returns a list inside a single via the getAllHistoryEntriesAsSingle() interface. The export functionality of my fork is already fully working if you want to test it. |
Renamed some comments and changed file extension from .txt to .json
File gets properly exported to .json now instead of .json.txt by changing the mime type from "text/plain" to "application/json"
Importing the history from a JSON file is fully functional. Still has to be tested.
So, importing is now fully implemented and working (but untested at the moment), now the question remains if I should add a dialog before that to allow the user to choose between deleting their history before importing it or not. Currently it gets deleted in the same transaction as it gets imported, which should prevent it from being completely deleted should something go wrong. With an if statement in there I could prevent the deletion, the only question is how do I access a bool set at BackupSettingsFragment from HistoryDatabase? This is where I lack the deeper knowledge on what Kotlin offers for solving that (or if there even is an elegant solution). I'd say it's not that important as the history can always get combined outside of Fulguris if really needed (one simple ctrl+c & ctrl+v) but some warning for the user would be nice. Perhaps name it "Replace current history with backup" or something along those lines? |
For now I would not delete the history while importing. User could still do that through the settings before importing. |
You can also just save a copy of your session without exporting it. |
No more resetting the history on importing, also does the same check as visitHistoryEntry now, therefore updating existing entries rather than duplicating them. Also fixed some comments.
So import should now be fully functional. I renamed the Import option to "Add history from backup" as I hope that reflects enough about what it does to the user. Now the question is if I should replace the already existing entries or just leave them and do nothing. Currently it updates them to what is in the JSON, but that could potentially make the history confusing if that page got visited later and then suddenly jumps "back in time" after the import. |
Prevents entries jumping back to the time saved in the backup.
@Cook-I-T Hi I'm really looking forward to this feature when will you do it? 🙃 |
Hey, sorry for my long absence, life's been too busy to work on this and now after all those months there are additionally merge conflicts to resolve which takes even more time (also I never had to deal with merge conflicts before so I have no clue what to do, yet). Best regards |
Sorry about the conflicts I just did some major refactoring. |
Once this PR is fully done exporting and importing the history should be easily possible.