bs-manager icon indicating copy to clipboard operation
bs-manager copied to clipboard

[feat-75] support drag and drop for map zip files

Open silentrald opened this issue 1 year ago β€’ 6 comments

Scope

closes #75

Implementation

Implemented drag and drop for map zip files.

Added Dropzone component to support drag and drop of files.

Created processZip in zip helper file to safely handle zip files, although SonarCloud doesn't seem to like the handling.

Added LocalMapsManagerService.importMap to import the zip file and copied almost the same code in downloadMap for pathing and caching.

Screenshots

image

How to Test

Drag and drop the following files:

  • Valid map zip file
  • Invalid zip file
  • Any non-zip file

Check if it will be installed in either the specific version folder or shared folder as well.

Check if switching to the playlist tab is not affected by the dropzone.

New Resource Text

List of added resource text

notifications.maps.import-map.titles.success: Map import complete notifications.maps.import-map.titles.error: An error occurred while importing the map notifications.maps.import-map.msgs.success: Imported all maps successfully notifications.maps.import-map.msgs.success: Imported some maps successfully notifications.maps.import-map.msgs.only-accept-zip: Only zip files are supported notifications.maps.import-map.msgs.not-found-zip: Zip file does not exists notifications.maps.import-map.msgs.invalid-zip: Zip file does not contain any dat files

Emoji Guide

For reviewers: Emojis can be added to comments to call out blocking versus non-blocking feedback.

E.g: Praise, minor suggestions, or clarifying questions that don’t block merging the PR.

🟒 Nice refactor!

🟑 Why was the default value removed?

E.g: Blocking feedback must be addressed before merging.

πŸ”΄ This change will break something important

Blocking πŸ”΄ ❌ 🚨 RED
Non-blocking 🟑 πŸ’‘ πŸ€” πŸ’­ Yellow, thinking, etc
Praise 🟒 πŸ’š 😍 πŸ‘ πŸ™Œ Green, hearts, positive emojis, etc

silentrald avatar Sep 05 '24 16:09 silentrald

@Zagrios Side tangent, seems that the call from observer.error shows the call stack error in the renderer. Seems the same as well for the other sendV2 <-> Observer interaction in the codebase as well. Might be a bug in the integration? But might check with you if this is expected.

image

image

silentrald avatar Sep 29 '24 10:09 silentrald

@Zagrios Side tangent, seems that the call from observer.error shows the call stack error in the renderer. Seems the same as well for the other sendV2 <-> Observer interaction in the codebase as well. Might be a bug in the integration? But might check with you if this is expected.

image

image

Yeah you need to handle the error in the frontend as well

Zagrios avatar Sep 29 '24 10:09 Zagrios

Yeah you need to handle the error in the frontend as well

Already did in the latest commit, the notification popup shows in the background when I close the error stack in the renderer so I'm not sure what part I've missed πŸ€”.

https://github.com/Zagrios/bs-manager/blob/1ccaad2e18d9f7c93c7830ced5350248aeed868e/src/renderer/services/maps-manager.service.ts#L163-L215

silentrald avatar Sep 29 '24 10:09 silentrald

Yeah you need to handle the error in the frontend as well

Already did in the latest commit, the notification popup shows in the background when I close the error stack in the renderer so I'm not sure what part I've missed πŸ€”.

https://github.com/Zagrios/bs-manager/blob/1ccaad2e18d9f7c93c7830ced5350248aeed868e/src/renderer/services/maps-manager.service.ts#L163-L215

The error comes from this line this.progressBar.show(importProgress$, true); Since the progressBarService shares the same observer, it also receives the error from it. You need to derive the main observer to create another one that doesn't receive any errors.

You can check the handleDownload() function in oculus-downloader.service.ts

Zagrios avatar Sep 29 '24 11:09 Zagrios

Ahhh gotcha, will amend the last commit so that the PR should be ready for a re-review.

silentrald avatar Sep 29 '24 11:09 silentrald

@silentrald I've just pushed some fixes, but I have to go.
I'm still encountering an error when I drop my zip file, as it doesn't find any Info.dat (see the gif). zip dont work I get this error message:

[1] 17:37:30.357 > Zip file "C:\Users\Mathieu\Desktop\1.37.3Maps.zip" does not contain any "Info.dat" file
[1] 17:37:30.358 > Error: No "Info.dat" file located in any of the zip files

The const files = zip.file(this.INFO_DAT_REGEX); results as empty array.

Zagrios avatar Oct 08 '24 15:10 Zagrios

@Zagrios might be related to the path separator. Not sure if Windows uses / or \, couldn't check this on my linux machine, though let me try to fix this in a Windows VM.

silentrald avatar Oct 08 '24 16:10 silentrald

@Zagrios got it to work on Windows.

Lost your commit though when I did a full rebase but I tried to reapply it on commit 615ac04. Might need to double check that, if I missed some lines, you can cherry pick the commit on your local to this PR.

silentrald avatar Oct 08 '24 17:10 silentrald

@silentrald can you test to confirm if its still working on Linux ?

Zagrios avatar Oct 17 '24 12:10 Zagrios

@Zagrios can confirm, works on Linux πŸ‘Œ

silentrald avatar Oct 17 '24 12:10 silentrald

Merging πŸ”₯πŸ”₯

Zagrios avatar Oct 17 '24 13:10 Zagrios