diff --git a/controller/action/AcquisitionActions.class.php b/controller/action/AcquisitionActions.class.php index 49a9629f..19dd46bd 100644 --- a/controller/action/AcquisitionActions.class.php +++ b/controller/action/AcquisitionActions.class.php @@ -29,12 +29,13 @@ class AcquisitionActions extends Actions public static function executeYoutubeToken() { $channelName = Request::encodeStringFromUser($_POST['desired_lbry_channel_name']); + $immediateSync = (boolean)$_POST['immediate_sync']; if ($channelName && $channelName[0] !== "@") { $channelName = '@' . $channelName; } - $token = LBRY::connectYoutube($channelName); + $token = LBRY::connectYoutube($channelName, $immediateSync); if ($token['success'] && $token['data']) { Controller::redirect($token['data']); diff --git a/lib/thirdparty/LBRY.class.php b/lib/thirdparty/LBRY.class.php index 6b4636a1..b475a010 100644 --- a/lib/thirdparty/LBRY.class.php +++ b/lib/thirdparty/LBRY.class.php @@ -50,22 +50,25 @@ class LBRY return Curl::post(static::getApiUrl('/user/unsubscribe'), ['email' => $email], ['json_response' => true]); } - public static function connectYoutube($channel_name) - { - $type = 'sync'; - + public static function connectYoutube($channel_name, $immediateSync = false) { // Uncomment next line for production and comment other return - return Curl::post(static::getApiUrl('/yt/new'), ['desired_lbry_channel_name' => $channel_name, 'type' => $type], ['json_response' => true]); - - // Uncomment next line for development and comment other return (this also requires the testnet API) // return Curl::post(static::getApiUrl('/yt/new'), [ // 'desired_lbry_channel_name' => $channel_name, - // 'immediate_sync' => true, - // 'return_url' => 'http://localhost:8000/youtube/status/', - // 'type' => $type + // 'immediate_sync' => $immediateSync, + // 'type' => 'sync' // ], [ // 'json_response' => true // ]); + + // Uncomment next line for development and comment other return (this also requires the testnet API) + return Curl::post(static::getApiUrl('/yt/new'), [ + 'desired_lbry_channel_name' => $channel_name, + 'immediate_sync' => $immediateSync, + 'return_url' => 'http://localhost:8000/youtube/status/', + 'type' => 'sync' + ], [ + 'json_response' => true + ]); } // Check the sync status diff --git a/web/js/yt2/app.js b/web/js/yt2/app.js index 4296d72f..a2d3ce40 100644 --- a/web/js/yt2/app.js +++ b/web/js/yt2/app.js @@ -250,6 +250,7 @@ new App(); +// Clicking CTAs introduces a smooth scroll to the appropriate section const youtubeCtas = document.querySelectorAll("[data-id='scroll-to-claim']"); youtubeCtas.forEach(cta => { @@ -264,3 +265,19 @@ youtubeCtas.forEach(cta => { }, 300); }; }); + + + +// Scroll to error messages if they exist +window.addEventListener("load", (event) => { + const youtubeErrors = document.querySelectorAll(".error-block"); + + youtubeErrors.forEach(error => { + if (!error.hidden) { + const errorDivOffset = error.offsetTop; + + window.scroll({ top: errorDivOffset }); + return; + } + }); +});