0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-21 17:00:29 +01:00

only run remote sub update retrieve on update action

Dieser Commit ist enthalten in:
merefield 2023-11-15 15:36:21 +00:00
Ursprung a82af2e016
Commit a58b13e9e4
4 geänderte Dateien mit 25 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,12 @@ class CustomWizard::SubscriptionController < ::Admin::AdminController
before_action :ensure_admin
def index
subscription = CustomWizard::Subscription.new
if params[:update_from_remote]
subscription = CustomWizard::Subscription.new(true)
else
subscription = CustomWizard::Subscription.new
end
render_json_dump(
subscribed: subscription.subscribed?,
subscription_type: subscription.type,

Datei anzeigen

@ -39,7 +39,7 @@ export default class WizardSubscriptionBadge extends Component {
update() {
this.updating = true;
this.updateIcon = "check";
this.subscription.retrieveSubscriptionStatus().finally(() => {
this.subscription.updateSubscriptionStatus().finally(() => {
this.updating = false;
setTimeout(() => {
this.updateIcon = null;

Datei anzeigen

@ -36,6 +36,19 @@ export default class SubscriptionService extends Service {
this.standardSubscription = this.subscriptionType === "standard";
}
async updateSubscriptionStatus() {
let result = await ajax("/admin/wizards/subscription?update_from_remote=true").catch(
popupAjaxError
);
this.subscribed = result.subscribed;
this.subscriptionType = result.subscription_type;
this.subscriptionAttributes = result.subscription_attributes;
this.businessSubscription = this.subscriptionType === "business";
this.communitySubscription = this.subscriptionType === "community";
this.standardSubscription = this.subscriptionType === "standard";
}
get subscriptionLink() {
return this.subscriptionLandingUrl;
}

Datei anzeigen

@ -106,8 +106,11 @@ class CustomWizard::Subscription
attr_accessor :product_id,
:product_slug
def initialize
::DiscourseSubscriptionClient::Subscriptions.update
def initialize(update = false)
if update
::DiscourseSubscriptionClient::Subscriptions.update
end
result = ::DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
if result&.any?