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

feat: Drop zone for save files #28

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

aniforprez
Copy link
Contributor

Found it cumbersome to continually navigate to my save file location and instead made a drop zone so I can keep the folder open and just drop the save file rather than deal with the navigator.

image

rockfactory and others added 3 commits November 10, 2024 23:08
Found it cumbersome to continually navigate to my save file location and
instead made a drop zone so I can keep the folder open and just drop the
save file rather than deal with the navigator
Copy link
Owner

@rockfactory rockfactory left a comment

Choose a reason for hiding this comment

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

I like the idea! I’ll give it a proper check later, in the meantime some things that come to my mind:

  • Is the accept prop ok for mantine/dropzone? I think it uses a different format, we should check it shows a reject icon and that it doesn’t allows to pick up other files with d&d
  • The border seems a bit strange in the video, is it just an artifact from video compression?

@rockfactory
Copy link
Owner

PS: Please target dev branch

@aniforprez
Copy link
Contributor Author

aniforprez commented Nov 12, 2024

The border in the video is just compression weirdness indeed. As the screenshot shows, it looks fine normally.

There does, in fact, seem to be some issue with dropzone not properly accepting .sav files. I'll have to check mime types here. It still uploads the save files and rejects other types but let me see what I can do to fix it. I tried it with PDF, PNG, JPEG and other files and it rejects them all as is expected.

@aniforprez aniforprez changed the base branch from main to dev November 12, 2024 09:46
The accept prop doesn't seem to properly deal with weird file types like
the Satisfactory save file since it wants proper mime types. Instead, we
are using a validator that will simply check the file extension. Since
we're dealing with weird binary files, this is bound to be sort of
weird.
@aniforprez
Copy link
Contributor Author

Switched to a custom validator logic since the accept prop technically worked but would throw warnings on console. The dropzone still throws a "reject" on dragOver because the browser doesn't handle these types of custom files well but once the file is dropped, it will check the file extension and only accept .sav files. All other file types are rejected.

Copy link
Owner

@rockfactory rockfactory left a comment

Choose a reason for hiding this comment

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

I fiddled with it and I get the validator thing, d&d file support is lacking. Anyway we still need to:

  • Provide the accept prop, since we need it when using normal file picker. Without it, it doesn't filter for save files
  • Show a clear error (e.g. under the Dropzone) if the dropped file is not valid. Right now there is a return { .. } in the validator function but the message is not shown if there are issues

@rockfactory rockfactory added the need changes Changes have been requested label Nov 13, 2024
@aniforprez
Copy link
Contributor Author

aniforprez commented Nov 13, 2024

Errors will be displayed under the dropzone. Let me know if you want any styling changes.

Also fixed the filtering on the file picker. Figuring it out was a doozy so I left a comment explaining the fix. File system access APIs don't work well with custom file types!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need changes Changes have been requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants