Review fixes to donation work

This commit is contained in:
Jim MacKenzie 2016-10-09 12:13:09 -05:00
commit e916a8076b
4 changed files with 20 additions and 14 deletions

View file

@ -28,31 +28,23 @@ namespace PlexRequests.UI.Modules
private async Task<Response> GetCustomDonationUrl(ISettingsService<PlexRequestSettings> pr)
{
PlexRequestSettings settings = pr.GetSettings();
PlexRequestSettings settings = await pr.GetSettingsAsync();
try
{
if (settings.EnableCustomDonationUrl)
{
JObject o = new JObject();
o["url"] = "\""+ settings.CustomDonationUrl + "\"";
o["message"] = "\"" + settings.CustomDonationMessage + "\"";
return Response.AsJson(o);
return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
}
else
{
JObject o = new JObject();
o["url"] = "https://www.paypal.me/PlexRequestsNet";
return Response.AsJson(o);
return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
}
}
catch (Exception e)
{
Log.Warn("Exception Thrown when attempting to check the custom donation url");
Log.Warn(e);
JObject o = new JObject();
o["url"] = "donationLinkError";
o["message"] = "\"" + "Donate to Library Maintainer" + "\"";
return Response.AsJson(o);
return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
}
}
}

View file

@ -443,4 +443,7 @@
<data name="Search_ViewInPlex" xml:space="preserve">
<value>View In Plex</value>
</data>
<data name="Custom_Donation_Default" xml:space="preserve">
<value>Donate to Library Maintainer</value>
</data>
</root>

View file

@ -114,6 +114,15 @@ namespace PlexRequests.UI.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Donate to Library Maintainer.
/// </summary>
public static string Custom_Donation_Default {
get {
return ResourceManager.GetString("Custom_Donation_Default", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Issue.
/// </summary>

View file

@ -39,7 +39,7 @@
{
<li><a id="donate" href="https://www.paypal.me/PlexRequestsNet" target="_blank"><i class="fa fa-heart" style="color: red"></i> @UI.Layout_Donate</a></li>
}
<li id="customDonate" style="display: none"><a id="customDonateHref" href="https://www.paypal.me/PlexRequestsNet" target="_blank"><i class="fa fa-heart" style="color: yellow;"></i> <span id="donationText">Donate to Library Maintainer</span></a></li>
<li id="customDonate" style="display: none"><a id="customDonateHref" href="https://www.paypal.me/PlexRequestsNet" target="_blank"><i class="fa fa-heart" style="color: yellow;"></i> <span id="donationText">@UI.Custom_Donation_Default</span></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
@ -94,8 +94,10 @@
</div>
</div>
<script>
var base = '@Html.GetBaseUrl()';
var url = createBaseUrl(base, '/customDonation');
$.ajax({
url: "/customDonation",
url: url,
success: function (result) {
console.log("we win + " + result.url);
if (result.url && result.url != "donationLinkError") {