1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

fix sync status display

This commit is contained in:
Luke Pulverenti 2015-10-02 02:14:04 -04:00
parent a07e6b59a3
commit 94a5cf7549
26 changed files with 415 additions and 276 deletions

View file

@ -1,8 +1,16 @@
(function () {
var unlockId = "com.mb.android.unlock";
var updatedProducts = [];
function getStoreFeatureId(feature) {
if (feature == 'embypremieremonthly') {
return "emby.supporter.monthly";
}
return "com.mb.android.unlock";
}
function updateProductInfo(id, owned, price) {
updatedProducts = updatedProducts.filter(function (r) {
@ -20,7 +28,10 @@
Events.trigger(IapManager, 'productupdated', [product]);
}
function getProduct(id) {
function getProduct(feature) {
var id = getStoreFeatureId(feature);
var products = updatedProducts.filter(function (r) {
return r.id == id;
});
@ -28,13 +39,14 @@
return products.length ? products[0] : null;
}
function isPurchaseAvailable(id) {
function isPurchaseAvailable(feature) {
return NativeIapManager.isStoreAvailable();
}
function beginPurchase(id) {
return MainActivity.beginPurchase(id);
function beginPurchase(feature, email) {
var id = getStoreFeatureId(feature);
return MainActivity.beginPurchase(id, email);
}
function onPurchaseComplete(result) {
@ -45,7 +57,31 @@
}
function refreshPurchases() {
NativeIapManager.isPurchased(unlockId, "window.IapManager.updateProduct");
NativeIapManager.isPurchased(getStoreFeatureId("") + "|" + getStoreFeatureId("embypremieremonthly"), "window.IapManager.updateProduct");
//NativeIapManager.isPurchased(getStoreFeatureId("embypremieremonthly"), "window.IapManager.updateProduct");
}
function getSubscriptionOptions() {
var deferred = DeferredBuilder.Deferred();
var options = [];
options.push({
feature: 'embypremieremonthly',
buttonText: 'EmbyPremiereMonthlyWithPrice'
});
options = options.filter(function (o) {
return getProduct(o.feature) != null;
}).map(function (o) {
o.buttonText = Globalize.translate(o.buttonText, o.price);
return o;
});
deferred.resolveWith(null, [options]);
return deferred.promise();
}
window.IapManager = {
@ -53,7 +89,9 @@
getProductInfo: getProduct,
updateProduct: updateProductInfo,
beginPurchase: beginPurchase,
onPurchaseComplete: onPurchaseComplete
onPurchaseComplete: onPurchaseComplete,
getStoreFeatureId: getStoreFeatureId,
getSubscriptionOptions: getSubscriptionOptions
};
refreshPurchases();