mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
Scrolling to errors and passing along sync status to YT sync works
This commit is contained in:
parent
ca1856e203
commit
48eab05b62
3 changed files with 32 additions and 11 deletions
|
@ -29,12 +29,13 @@ class AcquisitionActions extends Actions
|
||||||
public static function executeYoutubeToken()
|
public static function executeYoutubeToken()
|
||||||
{
|
{
|
||||||
$channelName = Request::encodeStringFromUser($_POST['desired_lbry_channel_name']);
|
$channelName = Request::encodeStringFromUser($_POST['desired_lbry_channel_name']);
|
||||||
|
$immediateSync = (boolean)$_POST['immediate_sync'];
|
||||||
|
|
||||||
if ($channelName && $channelName[0] !== "@") {
|
if ($channelName && $channelName[0] !== "@") {
|
||||||
$channelName = '@' . $channelName;
|
$channelName = '@' . $channelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = LBRY::connectYoutube($channelName);
|
$token = LBRY::connectYoutube($channelName, $immediateSync);
|
||||||
|
|
||||||
if ($token['success'] && $token['data']) {
|
if ($token['success'] && $token['data']) {
|
||||||
Controller::redirect($token['data']);
|
Controller::redirect($token['data']);
|
||||||
|
|
23
lib/thirdparty/LBRY.class.php
vendored
23
lib/thirdparty/LBRY.class.php
vendored
|
@ -50,22 +50,25 @@ class LBRY
|
||||||
return Curl::post(static::getApiUrl('/user/unsubscribe'), ['email' => $email], ['json_response' => true]);
|
return Curl::post(static::getApiUrl('/user/unsubscribe'), ['email' => $email], ['json_response' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function connectYoutube($channel_name)
|
public static function connectYoutube($channel_name, $immediateSync = false) {
|
||||||
{
|
|
||||||
$type = 'sync';
|
|
||||||
|
|
||||||
// Uncomment next line for production and comment other return
|
// 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'), [
|
// return Curl::post(static::getApiUrl('/yt/new'), [
|
||||||
// 'desired_lbry_channel_name' => $channel_name,
|
// 'desired_lbry_channel_name' => $channel_name,
|
||||||
// 'immediate_sync' => true,
|
// 'immediate_sync' => $immediateSync,
|
||||||
// 'return_url' => 'http://localhost:8000/youtube/status/',
|
// 'type' => 'sync'
|
||||||
// 'type' => $type
|
|
||||||
// ], [
|
// ], [
|
||||||
// 'json_response' => true
|
// '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
|
// Check the sync status
|
||||||
|
|
|
@ -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']");
|
const youtubeCtas = document.querySelectorAll("[data-id='scroll-to-claim']");
|
||||||
|
|
||||||
youtubeCtas.forEach(cta => {
|
youtubeCtas.forEach(cta => {
|
||||||
|
@ -264,3 +265,19 @@ youtubeCtas.forEach(cta => {
|
||||||
}, 300);
|
}, 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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue