-
-
Notifications
You must be signed in to change notification settings - Fork 733
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
Implementing showOpenDialog's web callback #2608
Merged
PrestonN
merged 21 commits into
FreeTubeApp:development
from
MarmadileManteater:implementing-dialog-boxes-in-web
Sep 23, 2022
Merged
Implementing showOpenDialog's web callback #2608
PrestonN
merged 21 commits into
FreeTubeApp:development
from
MarmadileManteater:implementing-dialog-boxes-in-web
Sep 23, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Adding a new function to make loading files from a dialog box easier in both web and electron
onchange is only triggered when the file picker has a file path. If the user cancels, this function is never called.
to prevent resolve from being called multiple times
to prevent this event from being triggered twice
efb4f5ff-1298-471a-8973-3d47447115dc
added
the
PR: waiting for review
For PRs that are complete, tested, and ready for review
label
Sep 22, 2022
github-actions
bot
removed
the
PR: waiting for review
For PRs that are complete, tested, and ready for review
label
Sep 23, 2022
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…-dialog-boxes-in-web # Conflicts: # src/renderer/components/data-settings/data-settings.js
auto-merge was automatically disabled
September 23, 2022 02:48
Head branch was pushed to by a user without write access
Conflicts have been resolved. A maintainer will review the pull request shortly. |
ChunkyProgrammer
requested review from
ChunkyProgrammer,
absidue,
efb4f5ff-1298-471a-8973-3d47447115dc and
PikachuEXE
September 23, 2022 04:35
ChunkyProgrammer
added
the
PR: waiting for review
For PRs that are complete, tested, and ready for review
label
Sep 23, 2022
PikachuEXE
approved these changes
Sep 23, 2022
absidue
approved these changes
Sep 23, 2022
ChunkyProgrammer
approved these changes
Sep 23, 2022
github-actions
bot
removed
the
PR: waiting for review
For PRs that are complete, tested, and ready for review
label
Sep 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementing
showOpenDialog
's web callbackPull Request Type
Please select what type of pull request this is:
Description
This PR implements
showOpenDialog
's web callback, and in order to do that meaningfully, it also refactors theimport
functions indata-settings
(importHistory
,importPlaylists
,importSubscriptions
, etc) to use a new utility function calledreadFileFromDialog
instead offs.readFile
.readFileFromDialog
normalizes the reading of files from a file picker between Electron and web builds. In Electron, the underlying behavior should be exactly the same, but in web builds, this change makes the import buttons indata-settings
work.It is worth noting that this change also hides the
Check for legacy subscriptions
button whenIS_ELECTRON
isfalse
. I figured this made sense because there is no way to check for that in a web browser without something like the native file API which has limited browser support at this time.Screenshots (if appropriate)
These screenshots are from a version of my web build with this PR applied to it.
Before:
After:
Testing (for code that is not small enough to be easily understandable)
This change effects all of the import buttons under
data-settings
. I have tested this with Electron and web builds on every type of subscription import, the playlist import, and the history import.The easiest way to test the subscriptions is to populate them ( either through using the app or from an existing data export ) and export them to all of the different types (db,csv,json,opml). Then, you can remove all of your subscriptions in the privacy settings and check each of the subscription export types with the exact same subscriptions.
Desktop (please complete the following information):
Additional context
In my opinion, the diff for
data-settings
is really hard to read, but I didn't remove much of any existing code. I moved all of the code inside thefs.readFile
callbacks to after the call forreadFileFromDialog
.I took code that looked like this:
And, I made it look like this:
I would be willing to refactor everything back to using a callback with
.then
if that would reduce the amount of additions/deletions in this PR. The reason I usedawait
over.then
was because I noticed thatthis.showOpenDialog
was being awaited, so I figured it made sense to also useawait
forthis.readFileFromDialog
.This change would take one step closer towards making an in-memory filesystem unnecessary for running FreeTube in web environments.