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

Stream queue #190

Merged
merged 6 commits into from
Jan 30, 2017
Merged

Stream queue #190

merged 6 commits into from
Jan 30, 2017

Conversation

dfirsht
Copy link
Member

@dfirsht dfirsht commented Jan 27, 2017

Resolves #127.

Check with design before merging.

Verified

This commit was signed with the committer’s verified signature.
fritzy Nathan Fritz

Verified

This commit was signed with the committer’s verified signature.
fritzy Nathan Fritz

Verified

This commit was signed with the committer’s verified signature.
fritzy Nathan Fritz
Copy link
Contributor

@glennrfisher glennrfisher left a comment

Choose a reason for hiding this comment

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

Nice. I think there are just a couple of small things to fix up.

@@ -100,6 +100,7 @@ class AddVideosViewController: UIViewController {
return
}
inviteVC.stream = stream
inviteVC.videoQueue = viewModel.selectedVideos.map{$0}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can avoid the map and just use viewModel.selectedVideos.

@@ -20,6 +20,8 @@ class InviteStreamViewController: UIViewController {
let headerCellHeight = CGFloat(47.0)

var stream: Stream?
// hold for streamVC
var videoQueue: [Video]?
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there different semantics for empty vs. nil? Would it make any sense to make this non-optional instead, but be initialized to an empty array? (And just a reminder that if you change it to be non-optional, there may be properties in other classes that can be non-optional as well, like computed vars that fetch this value.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I made it a nil since when it's the participant view the queue isn't just empty, it doesn't exist. It could be an empty array if that would make the code cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, okay. That makes sense. Sounds like there are separate meanings for [] and nil then.

"playsinline" : 1,
"modestbranding" : 1,
"showinfo" : 0,
"controls" : 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Making a note for myself to remember to check these lines when hiding controls for participants.

"controls" : 1,
"playlist": "7D3Ud2JIFhA, 2VuFqm8re5c"
])
if viewModel.isHost, let queue = viewModel.videoQueue, queue.count > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! I like the way you used multiple conditions here. Simple and easy to read.

@IBAction func backTapped(_ sender: Any) {
playerView.previousVideo()
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite follow why some of these @IBAction functions were removed, but I'm sure you have good reason. Just noting it here on the off chance that you didn't intend to commit it.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are from the debug arrows, they aren't needed anymore and don't work with the new system.

if tableView.tag == chatTableTag {
return cellFor(chatTableView: tableView, at: indexPath)
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be sliiiiightly easier to maintain if you use another if statement instead of an else.

if tableView.tag == chatTableTag {
return viewModel.messages.count //TODO: limit this to 50 or whatever performance allows
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be sliiiiightly easier to maintain if you use another if statement instead of an else.

}
else if destinationIndexPath.row == currentVideoIndex {
viewModel.currentVideoIndex = destinationIndexPath.row + (sourceIndexPath.row > destinationIndexPath.row ? 1 : -1)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think these conditions handle the case where a video is moved "over" the current video, from one side to the other.

For example: [video1, video2, current, video3, video4] -> [video1, video3, video2, current, video4]

// left-to-right
if sourceIndexPath.row < currentVideoIndex, currentIndexPath < destinationIndexPath.row {
    viewModel.currentIndexPath -= 1
}

// right-to-left
if sourceIndexPath.row > currentVideoIndex, currentIndexPath > destinationIndexPath.row {
    viewModel.currentIndexPath += 1
}

@@ -537,6 +625,12 @@ extension StreamViewController: YTPlayerViewDelegate {
}
break
case .ended:
if viewModel.isHost, let queue = viewModel.videoQueue, var queueIndex = viewModel.currentVideoIndex {
queueIndex = queueIndex < queue.count - 1 ? queueIndex + 1 : 0
Copy link
Contributor

Choose a reason for hiding this comment

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

queue.count - 1 is the last index of the array, so I think this will run-off the end if queueIndex is currently pointing to the last item. Consider changing the condition to queue.count - 2 instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

The condition is saying it will only increase the queueIndex if the current index is less than queue.count - 1. A bit hard to read but it is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha! You're right.

@@ -23,18 +23,31 @@ class StreamViewModel {

weak var delegate: StreamViewModelDelegate?

var stream: Stream
var stream: Stream? {
didSet {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not often that I see didSet. Neat to see it being used.

@glennrfisher
Copy link
Contributor

These changes look good! I'll get this design reviewed then merge the changes.

@glennrfisher
Copy link
Contributor

There are some design elements that need to be updated. Since this screen functions correctly, I think it's important to merge the changes and tackle other screens in the app. Then we can return to update the design.

So I'm going to merge this PR, but opened #196 to track the necessary design changes.

@glennrfisher glennrfisher merged commit 251030e into develop Jan 30, 2017
@glennrfisher glennrfisher deleted the streamQueue branch January 30, 2017 19:30
This was referenced Jan 30, 2017
dfirsht added a commit that referenced this pull request Feb 28, 2017
* video queue is collected and transfered to streamVC

* implemented queue and behaviors

* removed skip to stream button

* small changes based off feedback
dfirsht added a commit that referenced this pull request Mar 9, 2017
* video queue is collected and transfered to streamVC

* implemented queue and behaviors

* removed skip to stream button

* small changes based off feedback
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.

None yet

3 participants