Skip to content

Commit 7628afe

Browse files
committedNov 19, 2024
Rename creditInfo to subscriptionData
1 parent d311160 commit 7628afe

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed
 

‎packages/host/app/components/operator-mode/profile-info-popover.gts

+6-6
Original file line numberDiff line numberDiff line change
@@ -209,31 +209,31 @@ export default class ProfileInfoPopover extends Component<ProfileInfoPopoverSign
209209
@service declare matrixService: MatrixService;
210210

211211
private fetchCreditInfo = task(async () => {
212-
await this.realmServer.fetchCreditInfo();
212+
await this.realmServer.fetchSubscriptionData();
213213
});
214214

215215
@action private logout() {
216216
this.matrixService.logout();
217217
}
218218

219219
private get isLoading() {
220-
return this.realmServer.fetchingCreditInfo;
220+
return this.realmServer.fetchingSubscriptionData;
221221
}
222222

223223
private get plan() {
224-
return this.realmServer.creditInfo?.plan;
224+
return this.realmServer.subscriptionData?.plan;
225225
}
226226

227227
private get creditsIncludedInPlanAllowance() {
228-
return this.realmServer.creditInfo?.creditsIncludedInPlanAllowance;
228+
return this.realmServer.subscriptionData?.creditsIncludedInPlanAllowance;
229229
}
230230

231231
private get creditsAvailableInPlanAllowance() {
232-
return this.realmServer.creditInfo?.creditsAvailableInPlanAllowance;
232+
return this.realmServer.subscriptionData?.creditsAvailableInPlanAllowance;
233233
}
234234

235235
private get extraCreditsAvailableInBalance() {
236-
return this.realmServer.creditInfo?.extraCreditsAvailableInBalance;
236+
return this.realmServer.subscriptionData?.extraCreditsAvailableInBalance;
237237
}
238238

239239
private get monthlyCreditText() {

‎packages/host/app/services/realm-server.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ interface AvailableRealm {
4646
type: 'base' | 'catalog' | 'user';
4747
}
4848

49-
interface CreditInfo {
49+
interface SubscriptionData {
5050
plan: string | null;
5151
creditsAvailableInPlanAllowance: number | null;
5252
creditsIncludedInPlanAllowance: number | null;
@@ -56,7 +56,7 @@ interface CreditInfo {
5656
export default class RealmServerService extends Service {
5757
@service private declare network: NetworkService;
5858
@service private declare reset: ResetService;
59-
@tracked private _creditInfo: CreditInfo | null = null;
59+
@tracked private _subscriptionData: SubscriptionData | null = null;
6060
private auth: AuthStatus = { type: 'anonymous' };
6161
private client: ExtendedClient | undefined;
6262
private availableRealms = new TrackedArray<AvailableRealm>([
@@ -176,11 +176,11 @@ export default class RealmServerService extends Service {
176176
});
177177
}
178178

179-
async fetchCreditInfo() {
180-
if (this.creditInfo) {
179+
async fetchSubscriptionData() {
180+
if (this.subscriptionData) {
181181
return;
182182
}
183-
await this.fetchCreditInfoTask.perform();
183+
await this.fetchSubscriptionDataTask.perform();
184184
}
185185

186186
async handleRealmServerEvent(maybeRealmServerEvent: Partial<IEvent>) {
@@ -195,15 +195,15 @@ export default class RealmServerService extends Service {
195195
return;
196196
}
197197

198-
await this.fetchCreditInfoTask.perform();
198+
await this.fetchSubscriptionDataTask.perform();
199199
}
200200

201-
get creditInfo() {
202-
return this._creditInfo;
201+
get subscriptionData() {
202+
return this._subscriptionData;
203203
}
204204

205-
get fetchingCreditInfo() {
206-
return this.fetchCreditInfoTask.isRunning;
205+
get fetchingSubscriptionData() {
206+
return this.fetchSubscriptionDataTask.isRunning;
207207
}
208208

209209
async fetchCatalogRealms() {
@@ -239,9 +239,9 @@ export default class RealmServerService extends Service {
239239
return new URL(url);
240240
}
241241

242-
private fetchCreditInfoTask = dropTask(async () => {
242+
private fetchSubscriptionDataTask = dropTask(async () => {
243243
if (!this.client) {
244-
throw new Error(`Cannot fetch credit info without matrix client`);
244+
throw new Error(`Cannot fetch subscription data without matrix client`);
245245
}
246246
await this.login();
247247
if (this.auth.type !== 'logged-in') {
@@ -270,7 +270,7 @@ export default class RealmServerService extends Service {
270270
json.data?.attributes?.creditsIncludedInPlanAllowance ?? null;
271271
let extraCreditsAvailableInBalance =
272272
json.data?.attributes?.extraCreditsAvailableInBalance ?? null;
273-
this._creditInfo = {
273+
this._subscriptionData = {
274274
plan,
275275
creditsAvailableInPlanAllowance,
276276
creditsIncludedInPlanAllowance,

0 commit comments

Comments
 (0)