-
Notifications
You must be signed in to change notification settings - Fork 3
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
release/react #18
base: release/react
Are you sure you want to change the base?
release/react #18
Conversation
@@ -39,27 +39,34 @@ class DiscPanel extends Component { | |||
} | |||
|
|||
render(){ | |||
let discInfo = ''; | |||
if (this.state.discInfo.tracks && this.state.discInfo.tracks.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to conditionally display <DiscInfo />
. If DiscInfo's constructor fired without tracks
available, I got some wonky behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better way to do this would be something like:
discInfo = () => {
if(...) {
return null
}
return <DiscInfo ... />
}
Then just discInfo()
when using
/>s | ||
name={trackId} | ||
checked={this.state.selectedTracks[trackId].isSelected} | ||
onChange={(event) => this.toggleTrack(event)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I set the name to the trackId and used the event, I was able to determine if a track was selected without using jQuery, which I thought was nice; we could likely eliminate jQuery completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah jQuery is superfluous once React comes into play. I just didn't quite realize it back then ;)
if (selectedTrack.isSelected) { | ||
trackIds.push(trackId); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to use a .map(
function here, however for every track that I didn't return it would default to undefined. The result I wanted was something like: ['1', '5']
, however map would produce [undefined, '1', undefined, undefined, undefined, '5']
. I'm wondering if a filter
or reduce
method would be a better option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep you want reduce
}); | ||
this.getTrackCheckboxes(event.target) | ||
.prop('checked', this.state.checkAll); | ||
alert('This functionality is currently disabled.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add this back once I get ripping working.
I just noticed |
…contents and how we pop the last one off the set
@@ -213,7 +213,7 @@ class MakeMkv { | |||
trackIds.map((trackId) => this.ripQueue.driveId.add(trackId)); | |||
} | |||
|
|||
if (!this.ripQueue.driveId.length) { | |||
if (!this.ripQueue.driveId.size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of confused. driveId
is a Set, but you're interacting with it like it's an array. Not sure which you meant for it to be, so I stuck with a set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep this was wrong. Looks like the conditional doesn't do anything, so not really sure what I was going for honestly
@@ -224,7 +224,7 @@ class MakeMkv { | |||
}; | |||
|
|||
this.ripTrack( | |||
saveDirectory, driveId, this.ripQueue.driveId.pop(), newCallback | |||
saveDirectory, driveId, Array.from(this.ripQueue.driveId).pop(), newCallback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoping this actually removes the last element from the set and returns it; rather than just returning it. Hoping to test drive some of this stuff later on, but just trying to get things working quick-and-dirty for now with minimal change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't, and you can't access sets by index either. Better would probably be to just switch the set back to an array - it was just to clear up an edge case when someone submits the same track twice. It would only be possible if there are two UIs open talking to the server at the same time, and both submit the same track for ripping (within milliseconds of each other). Totally not going to happen outside of a lab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if you did want to handle this:
const ripTracks = [...this.ripQueue.driveId];
const ripTrack = ripTracks.pop();
this.ripQueue.driveId.delete(ripTrack);
Seems like a lot of work though, when we could accomplish the same functionality by just guarding the array push for the track
Found a few more small problems. Fixed a few, now I'm on to another issue, not quite sure what "file" argument this stacktrace is referring to at the moment. More investigating to do.
|
@TonyBrobston - I just saw this & it looks totally promising! I'll review this in depth and get back to you. Sorry for the crap state of this project code - it's been a while since this thing has seen some love. |
@lasley Thanks for the reply. No need to apologize about the state of things, lol. I'm just super glad this repo exists. As I find time I'll likely try to make improvements. Life has been busy, I imagine as it gets colder here in Iowa I'll find more time. If you help me with the remainder of getting this branch working, I'll slowly add fixes and enhancements as I use it. I've recently been using jest and eslint and have some interest in adding them to this repo. You've done an amazing job so far. I owe you a beer. |
Do you use the mainline branch? It's definitely worth checking out, even if it's not React.
Agreed on both of these. There's a long ago branch where I was adding lint and tests, but that was lost to the ether. Pretty sure I dropped it when the tests identified a crapton of bugs I didn't want to fix 😆 |
@lasley Here's what I have so far.
Everything seems right, however it doesn't rip the tracks selected. I'm wondering if I'm passing the parameters to the
socket.emit(
incorrectly.When I click "Rip Tracks" it fires the
actionRipTracks
fromapi.js
In this case the
discName
= "MARVELS_THE_AVENGERS",driveId
= "/dev/sr0", andtrackIds
= "['1']".When I dug in further to look at what your master branch does, I found this:
This makes it seem like I have the incorrect attribute names in the json.
Old looks to be:
rip_track
{
'save_dir': 'MARVELS_THE_AVENGERS',
'drive_id': '/dev/sr0',
'track_ids': ['1']
}
New looks to be:
doRipTracks
{
'discName': 'MARVELS_THE_AVENGERS',
'driveId': '/dev/sr0',
'trackIds': ['1']
}
Am I thinking of this correctly?