Improved YT sync visuals and accounted for pending email

This commit is contained in:
ポール ウェッブ 2019-04-17 14:53:34 -05:00
parent c6d5990629
commit ca1856e203
5 changed files with 34 additions and 17 deletions

View file

@ -5,13 +5,15 @@ class AcquisitionActions extends Actions
public static function executeYouTube(string $version = '') public static function executeYouTube(string $version = '')
{ {
$errorMessage = Request::getParam('error_message', ''); $errorMessage = Request::getParam('error_message', '');
if (Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR)) { if (Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR)) {
$errorMessage = Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR); $errorMessage = Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR);
} }
return ['acquisition/youtube', [ return ['acquisition/youtube', [
'reward' => LBRY::youtubeReward(), 'reward' => LBRY::youtubeReward(),
'error_message' => $errorMessage 'error_message' => $errorMessage
]]; ]];
} }
public static function executeVerify(string $token) public static function executeVerify(string $token)
@ -33,6 +35,7 @@ class AcquisitionActions extends Actions
} }
$token = LBRY::connectYoutube($channelName); $token = LBRY::connectYoutube($channelName);
if ($token['success'] && $token['data']) { if ($token['success'] && $token['data']) {
Controller::redirect($token['data']); Controller::redirect($token['data']);
} else { } else {
@ -44,16 +47,17 @@ class AcquisitionActions extends Actions
public static function executeYoutubeStatus(string $token) public static function executeYoutubeStatus(string $token)
{ {
$data = LBRY::statusYoutube($token); $data = LBRY::statusYoutube($token);
if (!$data['success']) { if (!$data['success']) {
Session::setFlash(Session::KEY_YOUTUBE_SYNC_ERROR, $data['error'] ?? "Error fetching your sync status."); Session::setFlash(Session::KEY_YOUTUBE_SYNC_ERROR, $data['error'] ?? "Error fetching your sync status.");
Controller::redirect('/youtube'); Controller::redirect('/youtube');
} }
return ['acquisition/youtube_status', [ return ['acquisition/youtube_status', [
'token' => $token, 'token' => $token,
'status_token' => $data, 'status_token' => $data,
'error_message' => Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR) 'error_message' => Session::getFlash(Session::KEY_YOUTUBE_SYNC_ERROR)
]]; ]];
} }
public static function actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent) public static function actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent)
@ -72,6 +76,7 @@ class AcquisitionActions extends Actions
Controller::redirect("/youtube/status/" . $status_token); Controller::redirect("/youtube/status/" . $status_token);
} }
} }
public static function executeYoutubeEdit() public static function executeYoutubeEdit()
{ {
return ['acquisition/youtube_edit']; return ['acquisition/youtube_edit'];

View file

@ -58,7 +58,14 @@ class LBRY
return Curl::post(static::getApiUrl('/yt/new'), ['desired_lbry_channel_name' => $channel_name, 'type' => $type], ['json_response' => true]); 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) // 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, 'type' => $type, 'return_url' => 'http://localhost:8000/youtube/status/'], ['json_response' => true]); // 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
// ], [
// 'json_response' => true
// ]);
} }
// Check the sync status // Check the sync status

View file

@ -47,6 +47,8 @@
if ($error_message): echo "<p class='error-block'>" . "The following error occurred: ". $error_message . " For support please send an email to <a href='mailto:hello@lbry.com' title='Email LBRY for help'>hello@lbry.com</a>." . "</p>"; if ($error_message): echo "<p class='error-block'>" . "The following error occurred: ". $error_message . " For support please send an email to <a href='mailto:hello@lbry.com' title='Email LBRY for help'>hello@lbry.com</a>." . "</p>";
endif;?> endif;?>
<p hidden id="lbry_error" class="error-block">LBRY channel name is either not valid or your input is blank</p>
<h2>Connect with your fans while earning money and rewards</h2> <h2>Connect with your fans while earning money and rewards</h2>
<form id="youtube_claim" method="post" action="/youtube/token"> <form id="youtube_claim" method="post" action="/youtube/token">
@ -65,8 +67,6 @@
type="submit" type="submit"
value="Claim now" value="Claim now"
/> />
<div hidden id="lbry_error" class="error">LBRY channel name is either not valid or your input is blank</div>
</input-submit> </input-submit>
<br/> <br/>

View file

@ -6,7 +6,7 @@
<?php Response::addJsAsset('//www.googleadservices.com/pagead/conversion_async.js') ?> <?php Response::addJsAsset('//www.googleadservices.com/pagead/conversion_async.js') ?>
<?php $statusData = $status_token['data'] ?> <?php $statusData = $status_token['data'] ?>
<?php $isSyncAgreed = in_array($statusData['status'], ["syncing", "synced", "queued", "failed", "finalized"]) ?> <?php $isSyncAgreed = in_array($statusData['status'], ["failed", "finalized", "pendingemail", "queued", "synced", "syncing"]) ?>
<?php $isRewardClaimed = $statusData['redeemed_reward'] > 0 ?> <?php $isRewardClaimed = $statusData['redeemed_reward'] > 0 ?>
<?php if (IS_PRODUCTION): ?> <?php if (IS_PRODUCTION): ?>
@ -50,12 +50,12 @@
</li> </li>
<li class="<?php echo $isSyncAgreed ? "" : "disabled" ?>"> <li class="<?php echo $isSyncAgreed ? "" : "disabled" ?>">
<span><?php echo $isSyncAgreed ? "" : "" ?></span> <span><?php echo $isSyncAgreed ? "" : "·" ?></span>
<p>Agree to sync</p> <p>Agree to sync</p>
</li> </li>
<li class="<?php echo $isRewardClaimed && $isSyncAgreed ? "" : "disabled" ?>"> <li class="<?php echo $isRewardClaimed && $isSyncAgreed ? "" : "disabled" ?>">
<span><?php echo $isRewardClaimed ? "" : "" ?></span> <span><?php echo $isRewardClaimed ? "" : "·" ?></span>
<p>Claim your credits</p> <p>Claim your credits</p>
<p <?php echo ($isRewardClaimed === false && $isSyncAgreed === true) ? "" : "hidden" ?>>(to get your credits, <a href="/get">download the app</a> and <a href="/faq/youtube">follow these instructions</a>)</p> <p <?php echo ($isRewardClaimed === false && $isSyncAgreed === true) ? "" : "hidden" ?>>(to get your credits, <a href="/get">download the app</a> and <a href="/faq/youtube">follow these instructions</a>)</p>
</li> </li>
@ -81,6 +81,9 @@
case "pending": case "pending":
echo __("Pending Agreement"); echo __("Pending Agreement");
break; break;
case "pendingemail":
echo __("Pending Email Confirmation");
break;
case "queued": case "queued":
echo __("Queued"); echo __("Queued");
break; break;
@ -99,19 +102,22 @@
case "abandoned": case "abandoned":
echo __("Cannot sync anymore!"); echo __("Cannot sync anymore!");
break; break;
default:
echo __("");
break;
} ?> } ?>
</td> </td>
<td> <td>
<?php echo $statusData['subscribers'] === 0 ? "-" : $statusData['subscribers'] ?> <?php echo $statusData['subscribers'] === 0 ? "" : $statusData['subscribers'] ?>
</td> </td>
<td> <td>
<?php echo $statusData['videos'] === 0 ? "-" : $statusData['videos'] ?> <?php echo $statusData['videos'] === 0 ? "" : $statusData['videos'] ?>
</td> </td>
<td> <td>
<?php echo $statusData['expected_reward'] === 0 ? "-" : $statusData['expected_reward'] ?> <?php echo $statusData['expected_reward'] === 0 ? "" : $statusData['expected_reward'] ?>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -258,7 +258,6 @@ $lbry-yt-blue: mix($lbry-blue-5, $lbry-black, 50%);
span { span {
background-color: var(--lbry-gray-3); background-color: var(--lbry-gray-3);
padding-top: 0.5rem; padding-top: 0.5rem;
padding-left: 0.05rem;
// Mobile Safari override // Mobile Safari override
@media not all and (min-resolution: 0.001dpcm) { @media not all and (min-resolution: 0.001dpcm) {