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

release/react #18

Open
wants to merge 22 commits into
base: release/react
Choose a base branch
from

Conversation

TonyBrobston
Copy link

@TonyBrobston TonyBrobston commented Sep 2, 2018

@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 from api.js

actionRipTracks(
    this.props.discName,
    this.props.driveId,
    trackIds
);

In this case the discName = "MARVELS_THE_AVENGERS", driveId = "/dev/sr0", and trackIds = "['1']".

When I dug in further to look at what your master branch does, I found this:

_this._socket_cmd('rip_track', {
    'save_dir': save_dir,
    'drive_id': drive_id,
    'track_ids': checked_boxes
})

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?

@@ -39,27 +39,34 @@ class DiscPanel extends Component {
}

render(){
let discInfo = '';
if (this.state.discInfo.tracks && this.state.discInfo.tracks.length > 0) {
Copy link
Author

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.

Copy link
Owner

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)}
Copy link
Author

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.

Copy link
Owner

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);
}
});
Copy link
Author

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.

Copy link
Owner

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.');
Copy link
Author

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.

@TonyBrobston
Copy link
Author

I just noticed makemkv.js, this explains a lot. I'll start looking here. Maybe adding some console logs will help me better understand what's going on.

…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) {
Copy link
Author

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.

Copy link
Owner

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
Copy link
Author

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.

Copy link
Owner

@lasley lasley Oct 13, 2018

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

Copy link
Owner

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

@TonyBrobston
Copy link
Author

TonyBrobston commented Sep 5, 2018

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.

Spawning "(exitCode, stdErr, stdOut) => {
            this.busyDevices.delete(driveId);
            let strOutput = stdOut.join('\n'),
                isSuccess = !exitCode && strOutput.indexOf('1 titles saved.') !== -1;
            callback(trackId, isSuccess, strOutput);
        }" with args: "--noscan,mkv,--cache=1024,--profile=/opt/node-makemkv/conversion_profile.xml,dev:/dev/sr1,0,/var/done/THE_ONION_MOVIE"
child_process.js:381
    throw new TypeError('"file" argument must be a non-empty string');
    ^

TypeError: "file" argument must be a non-empty string
    at normalizeSpawnArguments (child_process.js:381:11)
    at exports.spawn (child_process.js:494:38)
    at MakeMkv._spawn (/opt/node-makemkv/makemkv.js:457:23)
    at MakeMkv.ripTrack (/opt/node-makemkv/makemkv.js:259:14)
    at MakeMkv.ripTracks (/opt/node-makemkv/makemkv.js:226:14)
    at MakeMkvServer.doRipTracks (/opt/node-makemkv/server.js:250:22)
    at Socket.client.on (/opt/node-makemkv/server.js:207:51)
    at Socket.emit (events.js:180:13)
    at /opt/node-makemkv/node_modules/socket.io/lib/socket.js:513:12
    at process._tickCallback (internal/process/next_tick.js:176:11)

@lasley
Copy link
Owner

lasley commented Sep 18, 2018

@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.

@TonyBrobston
Copy link
Author

@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.

@lasley
Copy link
Owner

lasley commented Oct 13, 2018

@TonyBrobston

Do you use the mainline branch? It's definitely worth checking out, even if it's not React.

I've recently been using jest and eslint and have some interest in adding them to this repo.

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 😆

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

Successfully merging this pull request may close these issues.

2 participants