Skip to content

Commit

Permalink
chore: Replace getWithDefault with nullish coalescing (#5205)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal authored Oct 1, 2020
1 parent 32bf7c8 commit f3151a3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/components/modals/cropper-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class extends ModalBase {
onVisible() {
const viewport = {};
const factor = 150;
const aspectRatio = this.getWithDefault('aspectRatio', [2, 1]);
const aspectRatio = this.get('aspectRatio') ?? [2, 1];
viewport.width = aspectRatio[0] * factor;
viewport.height = aspectRatio[1] * factor;
viewport.type = 'square';
Expand Down
2 changes: 1 addition & 1 deletion app/components/orders/order-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class OrderSummary extends Component.extend(FormMixin) {
@computed('data.tickets', 'data.tickets.@each.attendees')
get total() {
return sumBy(this.data.tickets.toArray(),
ticket => (ticket.getWithDefault('price', 0) - ticket.getWithDefault('discount', 0)) * ticket.getWithDefault('attendees.length', 0)
ticket => (ticket.get('price') ?? 0 - ticket.get('discount') ?? 0) * ticket.get('attendees.length') ?? 0
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/events/view/tickets/add-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class AddOrderController extends Controller {
@computed('model.tickets.@each.orderQuantity')
get hasTicketsInOrder() {
return sumBy(this.model.tickets.toArray(),
ticket => ticket.getWithDefault('orderQuantity', 0)
ticket => ticket.get('orderQuantity') ?? 0
) > 0;
}

Expand Down
2 changes: 1 addition & 1 deletion app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Router extends RouterScroll {
_trackPage() {
scheduleOnce('afterRender', this, () => {
const page = this.url;
const title = this.getWithDefault('currentRouteName', 'unknown');
const title = this.get('currentRouteName') ?? 'unknown';
this.metrics.trackPage({ page, title });
this.set('session.currentRouteName', title);
});
Expand Down

1 comment on commit f3151a3

@vercel
Copy link

@vercel vercel bot commented on f3151a3 Oct 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.