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

[WIP] Button to delete tracks from playlist #378

Open
wants to merge 756 commits into
base: master
from

Conversation

@Hansen1992
Copy link
Contributor

@Hansen1992 Hansen1992 commented Jun 28, 2019

Hey nukeop, I made some changes in my effort to create a delete function that deletes tracks. So far it's not working but I'm pretty sure I've done something right some places. I tried to create a function just like the function that delete the entire playlists by mimicking some of the code from the "deletePlaylist" function. I just don't know, if that is even the right thing to do.

I appreciate the help and hope that the adding I made is not all bad.

Brn9hrd7 and others added 28 commits Feb 8, 2019
Remove '&' from last.fm track name
…en the album view

If the album is not found, we open the artist view.
Multiple queue popovers fix
Fix to #192 : add ability to click on album name in dashboard to open
Testing out Github actions
Feature/lyrics
Feature/dashboard/add and play track
Toast notifications, closes #169
Autoradio Averager + enhancement
Charles Jacquin
add remote-redux-devtool
The slider will be shown when an a min and a max value are given to the settings of a NUMBER setting
@nukeop

This comment has been minimized.

Copy link
Owner

@nukeop nukeop commented on app/components/Settings/index.js in 0e023d7 Feb 11, 2019

not 100% sure, but I think that this will be false of option.min is 0

This comment has been minimized.

Copy link
Collaborator Author

@trekiteasy trekiteasy replied Feb 12, 2019

Correct, thanks. Changed to a typeof option.min ==='number' && typeof option.max==='number'.

@nukeop

This comment has been minimized.

Copy link
Owner

@nukeop nukeop commented on app/containers/SoundContainer/autoradio.js in d188d42 Feb 11, 2019

if you're changing these from consts to regular variables, you should also change their names to regular camel case, since uppercase suggests const and could lead to some confusion

This comment has been minimized.

Copy link
Collaborator Author

@trekiteasy trekiteasy replied Feb 12, 2019

Agreed.

@nukeop
Copy link
Owner

@nukeop nukeop commented Jun 29, 2019

renamePlaylist(playlist, name) {

If you look at this function, renaming is accomplished by cloning the playlist, changing the name of the new copy, and calling updatePlaylist. The old playlist will be replaced with this copy, because they have the same id.

To delete a track from a playlist, you should create a similar function, that instead of changing the name of the cloned playlist will filter its tracks (just don't use _.remove, on the original playlist, because it mutates the state, and that's a big no-no in Redux). An example of what the filtering could look like:

updatedPlaylist.tracks = _.filter(updatedPlaylist.tracks, track => track.id !== trackToRemove.id )

BTW. This workflow makes me think it'd be a good idea to prepare a couple of simple functionalities to implement for people who are learning and would like to contribute to some open source project but who don't feel too confident yet, so that they can solve a real life problem while being guided in a friendly way, both learning and contributing.

@Hansen1992
Copy link
Contributor Author

@Hansen1992 Hansen1992 commented Jun 29, 2019

Thanks for the guidance, I'll try my best to implement the above example-code into a delete-track function!

To answer your above-mentioned idea about making some issues that contain a couple of simple functionalities to implement for people who are learning and would like to contribute to some open source project:
I'm currently working as a curator in Denmark but while taking some upgrading IT courses, I was absolutely overwhelmed with awe when I found out what you could do with code.
I'm currently preparing myself and my skills for searching for jobs in the software-developing industry and none of my friends know anything about code, so for you to help me solve this issue in your app means the world to me. You not only learn how to decode another persons work but you also learn how things are connected and mapped in a framework like react.
I'm sure others, who are in a similar situation as I'm in, and are trying to detach themselves from youtube tutorials and actually throw themselves at a real issue that needs to be solved for a real app will benefit greatly from it just as it has benefitted me.

@Hansen1992

This comment has been minimized.

Copy link
Contributor Author

@Hansen1992 Hansen1992 commented on 620700a Jun 29, 2019

The code is still not quite working as I want it to work and I can't really read me to what mistake I have made. Can you see what I haven't gone right?

@nukeop
Copy link
Owner

@nukeop nukeop commented Jun 29, 2019

It was right to have removeTrack have id as its argument. That's the information by which you can distinguish the tracks on the playlist. You don't need to touch actions/playlists.js. The place for this function is in PlaylistView/index.js, in the PlaylistView class.

Take a look how renamePlaylist updates the playlists (starts here:

renamePlaylist(playlist, name) {
).
You have to do something similar, except instead of changing the name you are going to change the list of the tracks. As a hint, you're going to need the playlist and the track id as arguments.

The steps that you'll need to take are:

  • clone the original playlist
  • filter out the track clicked by the user
  • replace the cloned playlist's track list with the filtered one
  • update the playlist using the clone

And then after you have this function, you can connect it to the button like you already did (by supplying it in the onDelete prop of TrackRow).

@Hansen1992
Copy link
Contributor Author

@Hansen1992 Hansen1992 commented Jun 29, 2019

Thanks, I'll give it my best shot!

@Hansen1992

This comment has been minimized.

Copy link
Contributor Author

@Hansen1992 Hansen1992 commented on e8dd7ed Jul 3, 2019

Hey @nukeop , I know my attempt is a trainwreck of a code, but I simply cannot make the deleteTrack-code work. The more I read about React and how it all works, the more confused and lost I feel.
I have tried to clone the existing tracklist and then use that tracklist as the new version where the deleted track is filtered out. It just doesn't work yet.

@nukeop
Copy link
Owner

@nukeop nukeop commented Jul 3, 2019

You almost got it. Just remember that you don't have to modify anything in actions/playlists.js to make this work. You can revert your changes there. Maybe I'm explaining this too chaotically. I'll try to explain it better in a bit.

@Hansen1992
Copy link
Contributor Author

@Hansen1992 Hansen1992 commented Jul 20, 2019

Hi nuke, I'm sorry it's been a while since I last made a pull request, I've been on vacation.
I deleted the code I had made in actions/playlists.js, so this should now be in order.

@nukeop
Copy link
Owner

@nukeop nukeop commented Jul 20, 2019

No problems, we don't have deadlines here. You can contribute at your own pace. I'll test your code now.

@Hansen1992
Copy link
Contributor Author

@Hansen1992 Hansen1992 commented Jul 28, 2019

The code is still not working, but I'm pretty sure I'm getting close.

@Hansen1992
Copy link
Contributor Author

@Hansen1992 Hansen1992 commented Aug 5, 2019

Hey @nukeop this should be the final and working code if I'm not wrong :-)

@nukeop
Copy link
Owner

@nukeop nukeop commented Aug 5, 2019

Yes, I think you've nailed it. I'll verify so that we're 100% sure.

Btw, this could be a good opportunity to add a test for this function too. I'll check if I can add code to your branch and if not I'll add it in a comment and ask you to commit it, if you agree.

@nukeop nukeop added the under review label Aug 5, 2019
@nukeop
Copy link
Owner

@nukeop nukeop commented Aug 5, 2019

I noticed that you need to add a new field to the track table header at the beginning.

2019-08-06-011506_795x134_scrot

@nukeop
Copy link
Owner

@nukeop nukeop commented Aug 5, 2019

I'll add the tests after you correct this small issue and merge everything, so you don't have to worry about it.

@nukeop
Copy link
Owner

@nukeop nukeop commented Aug 5, 2019

4ebaf74

This is how I intend to test the updatePlaylist function after your changes, for reference. I implemented dependency injection for deletePlaylist here, updatePlaylist will be refactored similarly.

@nukeop nukeop added needs changes and removed under review labels Aug 7, 2019
@Hansen1992
Copy link
Contributor Author

@Hansen1992 Hansen1992 commented Aug 25, 2019

Hi Nuke, I'm experiencing some issues with opening the app on my computer common to the error I've had before with only the logo of the app appearing when running the app in the browser. Even though I am pretty sure I can code the last bit without looking at the result of the code in the app, I still want to make sure it works before I push it to Github. I just want to make you know, that I haven't forgot about this issue and that i'll soon be pushing the final bit of code up :-)

@nukeop
Copy link
Owner

@nukeop nukeop commented Aug 27, 2019

No problem, take as much time as you need.

@nukeop nukeop force-pushed the nukeop:master branch from 13f1d88 to 81de3d1 Sep 30, 2019
@Hansen1992
Copy link
Contributor Author

@Hansen1992 Hansen1992 commented Oct 5, 2019

Hi nuke, I finally got time again to work on this project, as I have been taking a bunch of React courses and freelance work to really understand what this app is all about and how it really works. It's been a time since I've last worked in the dev version of Nuclear and now my gitbash throws me an error every time I try to use npm run:watch in the app directory saying ''webpack-dev-server' is not recognized as an internal or external command'. I downloaded webpack for this project, but is does not seem to work, do you have any suggestions for why this error might appear?

@nukeop
Copy link
Owner

@nukeop nukeop commented Oct 5, 2019

I've changed the architecture in a major way recently. You can either try using docker (it's just one command to run dev mode now), or you could clone the repo, cd to packages/app, and run the program the old way (npm run watch, and npm run electron:dev in a separate shell).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

You can’t perform that action at this time.