Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 01:10:28 +01:00
make subscription update happen asynchronously on FE
Dieser Commit ist enthalten in:
Ursprung
6be518f0e1
Commit
8e2b117321
3 geänderte Dateien mit 19 neuen und 35 gelöschten Zeilen
|
@ -2,6 +2,7 @@
|
||||||
@action={{this.click}}
|
@action={{this.click}}
|
||||||
class="wizard-subscription-badge {{this.subscription.subscriptionType}}"
|
class="wizard-subscription-badge {{this.subscription.subscriptionType}}"
|
||||||
@title={{this.title}}
|
@title={{this.title}}
|
||||||
|
{{did-insert this.update}}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
width="300px"
|
width="300px"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import { action, computed } from "@ember/object";
|
import { action, computed } from "@ember/object";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { tracked } from "@glimmer/tracking";
|
import { tracked } from "@glimmer/tracking";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
@ -39,24 +37,13 @@ export default class WizardSubscriptionBadge extends Component {
|
||||||
|
|
||||||
@action
|
@action
|
||||||
update() {
|
update() {
|
||||||
this.subscription.retrieveSubscriptionStatus();
|
this.updating = true;
|
||||||
// this.updating = true;
|
this.updateIcon = "check";
|
||||||
// return ajax(`${this.basePath}/subscriptions`, {
|
this.subscription.retrieveSubscriptionStatus().finally(() => {
|
||||||
// type: "POST",
|
this.updating = false;
|
||||||
// })
|
setTimeout(() => {
|
||||||
// .then(() => {
|
this.updateIcon = null;
|
||||||
// if (this.subscription.subscribed) {
|
}, 5000);
|
||||||
// this.updateIcon = "check";
|
})
|
||||||
// } else {
|
|
||||||
// this.updateIcon = "times";
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch(popupAjaxError)
|
|
||||||
// .finally(() => {
|
|
||||||
// this.updating = false;
|
|
||||||
// setTimeout(() => {
|
|
||||||
// this.updateIcon = null;
|
|
||||||
// }, 7000);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,19 +23,15 @@ export default class SubscriptionService extends Service {
|
||||||
this.retrieveSubscriptionStatus();
|
this.retrieveSubscriptionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
retrieveSubscriptionStatus() {
|
async retrieveSubscriptionStatus() {
|
||||||
debugger;
|
let result = await ajax("/admin/wizards/subscription").catch(popupAjaxError);
|
||||||
ajax("/admin/wizards/subscription")
|
|
||||||
.then((result) => {
|
this.subscribed = result.subscribed;
|
||||||
debugger;
|
this.subscriptionType = result.subscription_type;
|
||||||
this.subscribed = result.subscribed;
|
this.subscriptionAttributes = result.subscription_attributes;
|
||||||
this.subscriptionType = result.subscription_type;
|
this.businessSubscription = this.subscriptionType === "business";
|
||||||
this.subscriptionAttributes = result.subscription_attributes;
|
this.communitySubscription = this.subscriptionType === "community";
|
||||||
this.businessSubscription = this.subscriptionType === "business";
|
this.standardSubscription = this.subscriptionType === "standard";
|
||||||
this.communitySubscription = this.subscriptionType === "community";
|
|
||||||
this.standardSubscription = this.subscriptionType === "standard";
|
|
||||||
})
|
|
||||||
.catch(popupAjaxError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get subscriptionLink() {
|
get subscriptionLink() {
|
||||||
|
|
Laden …
In neuem Issue referenzieren