Allow only images in modal image uploader. #7672

Merged
Ruk33 commented 2022-08-11 20:08:59 +02:00 (Migrated from github.com)

Fixes

Issue Number: https://github.com/lbryio/lbry-desktop/issues/7646

What is the current behavior?

Even though a file filter is being used, the "All Files"
option allows users to select any file when uploading
an image.

What is the new behavior?

The electron filter is being used so the "All Files"
option is no longer displayed.

image

Other information

PR Checklist

Toggle...

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting)
  • Refactoring (no functional changes)
  • Documentation changes
  • Other - Please describe:

Please check all that apply to this PR using "x":

  • I have checked that this PR is not a duplicate of an existing PR (open, closed or merged)
  • I added a line describing my change to CHANGELOG.md
  • I have checked that this PR does not introduce a breaking change
  • This PR introduces breaking changes and I have provided a detailed explanation below
## Fixes Issue Number: https://github.com/lbryio/lbry-desktop/issues/7646 <!-- Tip: - Add keywords to directly close the Issue when the PR is merged. - Skip the keyword if the Issue contains multiple items. - https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword --> ## What is the current behavior? Even though a file filter is being used, the "All Files" option allows users to select any file when uploading an image. ## What is the new behavior? The electron filter is being used so the "All Files" option is no longer displayed. ![image](https://user-images.githubusercontent.com/1719111/184208937-a89cea19-cdcb-436e-85a6-eab8309687eb.png) ## Other information <!-- If this PR contains a breaking change, please describe the impact and solution strategy for existing applications below. --> ## PR Checklist <!-- For the checkbox formatting to work properly, make sure there are no spaces on either side of the "x" --> <details><summary>Toggle...</summary> What kind of change does this PR introduce? - [x] Bugfix - [ ] Feature - [ ] Code style update (formatting) - [ ] Refactoring (no functional changes) - [ ] Documentation changes - [ ] Other - Please describe: Please check all that apply to this PR using "x": - [x] I have checked that this PR is not a duplicate of an existing PR (open, closed or merged) - [ ] I added a line describing my change to CHANGELOG.md - [x] I have checked that this PR does not introduce a breaking change - [ ] This PR introduces breaking changes and I have provided a detailed explanation below </details>
jessopb (Migrated from github.com) reviewed 2022-08-12 05:02:38 +02:00
jessopb (Migrated from github.com) commented 2022-08-12 05:02:37 +02:00

I'm concerned that changing this from { path } to file will break publishing. Did you try?
b9be8d9f3a/ui/component/publishFile/view.jsx (L273) expects file.path on electron because the sdk needs the path.

It may be good to send { file: file , path: path } and adjust all the functions assigned to onFileChosen to take that.

I'm concerned that changing this from { path } to file will break publishing. Did you try? https://github.com/lbryio/lbry-desktop/blob/b9be8d9f3a80d06c3e620ad12fc692f907c46223/ui/component/publishFile/view.jsx#L273 expects file.path on electron because the sdk needs the path. It may be good to send { file: file , path: path } and adjust all the functions assigned to onFileChosen to take that.
Ruk33 (Migrated from github.com) reviewed 2022-08-12 20:52:51 +02:00
Ruk33 (Migrated from github.com) commented 2022-08-12 20:52:51 +02:00

Sounds good @jessopb, nice catch. Perhaps as a small note for the future, we should avoid using these union types. Notice how I'm still respecting the interface (by sending a File type) but still, it manages to break parts of the app...

Sounds good @jessopb, nice catch. Perhaps as a small note for the future, we should avoid using these union types. Notice how I'm still respecting the interface (by sending a `File` type) but still, it manages to break parts of the app...
jessopb (Migrated from github.com) reviewed 2022-08-12 22:52:14 +02:00
jessopb (Migrated from github.com) commented 2022-08-12 22:52:14 +02:00

You're probably right. The union types were originally added when the codebase was supporting both web and app.

Maybe the type should be ChosenFile = { file: WebFile, path: string }

You're probably right. The union types were originally added when the codebase was supporting both web and app. Maybe the type should be ChosenFile = { file: WebFile, path: string }
Ruk33 (Migrated from github.com) reviewed 2022-08-13 00:24:26 +02:00
Ruk33 (Migrated from github.com) commented 2022-08-13 00:24:25 +02:00

@jessopb I have updated the code so the File now contains a path and a mime type. With this, the file upload for posts works fine. Please let me know what you think. Thanks.

@jessopb I have updated the code so the `File` now contains a `path` and a `mime` type. With this, the file upload for posts works fine. Please let me know what you think. Thanks.
jessopb (Migrated from github.com) reviewed 2022-08-15 15:15:48 +02:00
jessopb (Migrated from github.com) commented 2022-08-15 15:15:33 +02:00

This was an elegant solution, but I think WebFile is a well defined builtin type and probably shouldn't be polluted with extra params. I think we'd prefer { file: FILE, path: path }

This was an elegant solution, but I think WebFile is a well defined builtin type and probably shouldn't be polluted with extra params. I think we'd prefer { file: FILE, path: path }
jessopb (Migrated from github.com) requested changes 2022-08-26 18:02:04 +02:00
jessopb (Migrated from github.com) left a comment

Sorry it took a while to get to this. Tested publish and it's broken.

Sorry it took a while to get to this. Tested publish and it's broken.
jessopb (Migrated from github.com) commented 2022-08-26 18:01:49 +02:00

Also breaks here on file drop. This should be a path.

Also breaks here on file drop. This should be a path.
jessopb (Migrated from github.com) commented 2022-08-26 17:58:03 +02:00

Did you try publishing? Publish is trying to send an empty {}. (What happens when { thing: undefined })

Did you try publishing? Publish is trying to send an empty {}. (What happens when { thing: undefined })
jessopb (Migrated from github.com) approved these changes 2022-08-30 18:40:06 +02:00
jessopb (Migrated from github.com) requested changes 2022-08-30 21:22:59 +02:00
jessopb (Migrated from github.com) left a comment

One small snag.

One small snag.
jessopb (Migrated from github.com) commented 2022-08-30 21:22:47 +02:00

this blocks jpeg - possibly some other valid types. svg has been possible and allowed so far.

this blocks `jpeg` - possibly some other valid types. svg has been possible and allowed so far.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#7672
No description provided.