From d9436a68a14f0e3426fd86750f6b30a82c74cfa1 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Sun, 16 Oct 2022 21:47:08 -0400 Subject: [PATCH] Fixed minor contribution bug --- js/beestat/user.js | 17 +++++++++++++---- js/component/card/contribute.js | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/js/beestat/user.js b/js/beestat/user.js index 7d036c9..45dee4b 100644 --- a/js/beestat/user.js +++ b/js/beestat/user.js @@ -3,7 +3,7 @@ beestat.user = {}; /** * Determine whether or not the current user is an active Patron. * - * @return {boolean} true if yes, false if no. + * @return {boolean} */ beestat.user.patreon_is_active = function() { const user = beestat.user.get(); @@ -16,7 +16,7 @@ beestat.user.patreon_is_active = function() { /** * Determine whether or not the current user is an active Stripe giver. * - * @return {boolean} true if yes, false if no. + * @return {boolean} */ beestat.user.stripe_is_active = function() { const stripe_events = Object.values(beestat.cache.stripe_event); @@ -32,6 +32,16 @@ beestat.user.stripe_is_active = function() { return false; }; +/** + * Determine whether or not hte current user is an active contributor. + * + * @return {boolean} + */ +beestat.user.contribution_is_active = function() { + return beestat.user.patreon_is_active() === true || + beestat.user.stripe_is_active() === true; +}; + /** * Is the user connected to Patreon. * @@ -49,8 +59,7 @@ beestat.user.patreon_is_connected = function() { beestat.user.has_early_access = function() { const user = beestat.user.get(); return user.user_id === 1 || - beestat.user.stripe_is_active() === true || - beestat.user.patreon_is_active() === true; + beestat.user.contribution_is_active() === true; }; /** diff --git a/js/component/card/contribute.js b/js/component/card/contribute.js index ae245b0..44a4d32 100644 --- a/js/component/card/contribute.js +++ b/js/component/card/contribute.js @@ -21,7 +21,7 @@ beestat.extend(beestat.component.card.contribute, beestat.component.card); beestat.component.card.contribute.prototype.decorate_contents_ = function(parent) { const self = this; - if (beestat.user.has_early_access() === true) { + if (beestat.user.contribution_is_active() === true) { const p1 = document.createElement('p'); p1.innerText = 'Thank you so much for your support! Your contribution goes a long way towards keeping beestat running and enabling me to create a rich and useful application. My hope is that you are able to use beestat to save money and improve the efficiency of your home.'; parent.appendChild(p1); @@ -290,7 +290,7 @@ beestat.component.card.contribute.prototype.get_title_ = function() { * @param {rocket.Elements} parent */ beestat.component.card.contribute.prototype.decorate_top_right_ = function(parent) { - if (beestat.user.has_early_access() === false) { + if (beestat.user.contribution_is_active() === false) { const menu = (new beestat.component.menu()).render(parent); menu.add_menu_item(new beestat.component.menu_item()