reload study video and better handle invalid URLs

This commit is contained in:
Thibault Duplessis 2017-08-19 18:26:19 -05:00
parent ae689824ce
commit 6492f9e35b
2 changed files with 6 additions and 2 deletions

View file

@ -479,7 +479,8 @@ final class StudyApi(
val shouldReload =
(newChapter.setup.orientation != chapter.setup.orientation) ||
(newChapter.practice != chapter.practice) ||
(newChapter.gamebook != chapter.gamebook)
(newChapter.gamebook != chapter.gamebook) ||
(newChapter.embed != chapter.embed)
if (study.position.chapterId == chapter.id && shouldReload)
sendTo(study, Socket.ChangeChapter(uid, study.position))
else

View file

@ -141,7 +141,10 @@ export function main(ctrl: StudyCtrl): VNode {
return embedUrl ? h('div', [
sideBox,
h('div.side_box.embed', {
hook: innerHTML(embedUrl, t => toYouTubeEmbed(t, 140)!)
hook: innerHTML(embedUrl, t => {
const html = toYouTubeEmbed(t, 140);
return html || (ctrl.members.canContribute() ? 'Invalid YouTube URL' : '')
})
})
]) : sideBox;
}