Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 01:10:28 +01:00
only run remote sub update retrieve on update action
Dieser Commit ist enthalten in:
Ursprung
a82af2e016
Commit
a58b13e9e4
4 geänderte Dateien mit 25 neuen und 4 gelöschten Zeilen
|
@ -3,7 +3,12 @@ class CustomWizard::SubscriptionController < ::Admin::AdminController
|
||||||
before_action :ensure_admin
|
before_action :ensure_admin
|
||||||
|
|
||||||
def index
|
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(
|
render_json_dump(
|
||||||
subscribed: subscription.subscribed?,
|
subscribed: subscription.subscribed?,
|
||||||
subscription_type: subscription.type,
|
subscription_type: subscription.type,
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default class WizardSubscriptionBadge extends Component {
|
||||||
update() {
|
update() {
|
||||||
this.updating = true;
|
this.updating = true;
|
||||||
this.updateIcon = "check";
|
this.updateIcon = "check";
|
||||||
this.subscription.retrieveSubscriptionStatus().finally(() => {
|
this.subscription.updateSubscriptionStatus().finally(() => {
|
||||||
this.updating = false;
|
this.updating = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.updateIcon = null;
|
this.updateIcon = null;
|
||||||
|
|
|
@ -36,6 +36,19 @@ export default class SubscriptionService extends Service {
|
||||||
this.standardSubscription = this.subscriptionType === "standard";
|
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() {
|
get subscriptionLink() {
|
||||||
return this.subscriptionLandingUrl;
|
return this.subscriptionLandingUrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,11 @@ class CustomWizard::Subscription
|
||||||
attr_accessor :product_id,
|
attr_accessor :product_id,
|
||||||
:product_slug
|
:product_slug
|
||||||
|
|
||||||
def initialize
|
def initialize(update = false)
|
||||||
::DiscourseSubscriptionClient::Subscriptions.update
|
if update
|
||||||
|
::DiscourseSubscriptionClient::Subscriptions.update
|
||||||
|
end
|
||||||
|
|
||||||
result = ::DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
|
result = ::DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
|
||||||
|
|
||||||
if result&.any?
|
if result&.any?
|
||||||
|
|
Laden …
In neuem Issue referenzieren