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

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>";
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>
<form id="youtube_claim" method="post" action="/youtube/token">
@ -65,8 +67,6 @@
type="submit"
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>
<br/>

View file

@ -6,7 +6,7 @@
<?php Response::addJsAsset('//www.googleadservices.com/pagead/conversion_async.js') ?>
<?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 if (IS_PRODUCTION): ?>
@ -50,12 +50,12 @@
</li>
<li class="<?php echo $isSyncAgreed ? "" : "disabled" ?>">
<span><?php echo $isSyncAgreed ? "" : "" ?></span>
<span><?php echo $isSyncAgreed ? "" : "·" ?></span>
<p>Agree to sync</p>
</li>
<li class="<?php echo $isRewardClaimed && $isSyncAgreed ? "" : "disabled" ?>">
<span><?php echo $isRewardClaimed ? "" : "" ?></span>
<span><?php echo $isRewardClaimed ? "" : "·" ?></span>
<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>
</li>
@ -81,6 +81,9 @@
case "pending":
echo __("Pending Agreement");
break;
case "pendingemail":
echo __("Pending Email Confirmation");
break;
case "queued":
echo __("Queued");
break;
@ -99,19 +102,22 @@
case "abandoned":
echo __("Cannot sync anymore!");
break;
default:
echo __("");
break;
} ?>
</td>
<td>
<?php echo $statusData['subscribers'] === 0 ? "-" : $statusData['subscribers'] ?>
<?php echo $statusData['subscribers'] === 0 ? "" : $statusData['subscribers'] ?>
</td>
<td>
<?php echo $statusData['videos'] === 0 ? "-" : $statusData['videos'] ?>
<?php echo $statusData['videos'] === 0 ? "" : $statusData['videos'] ?>
</td>
<td>
<?php echo $statusData['expected_reward'] === 0 ? "-" : $statusData['expected_reward'] ?>
<?php echo $statusData['expected_reward'] === 0 ? "" : $statusData['expected_reward'] ?>
</td>
</tr>
</tbody>

View file

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