Commit fd47fa51 authored by Kushal Pandya's avatar Kushal Pandya Committed by Mario de la Ossa

Change `subscription` store property to `subscribed`

parent 9c1e042d
...@@ -177,13 +177,13 @@ ...@@ -177,13 +177,13 @@
this.toggleSidebar(); this.toggleSidebar();
} }
}, },
handleToggleSubscription() { handleToggleSubscribed() {
this.service.toggleSubscription() this.service.toggleSubscribed()
.then(() => { .then(() => {
this.store.setSubscription(!this.store.subscription); this.store.setSubscribed(!this.store.subscribed);
}) })
.catch(() => { .catch(() => {
if (this.store.subscription) { if (this.store.subscribed) {
Flash(__('An error occurred while unsubscribing to notifications.')); Flash(__('An error occurred while unsubscribing to notifications.'));
} else { } else {
Flash(__('An error occurred while subscribing to notifications.')); Flash(__('An error occurred while subscribing to notifications.'));
...@@ -260,8 +260,8 @@ ...@@ -260,8 +260,8 @@
/> />
<sidebar-subscriptions <sidebar-subscriptions
:loading="savingSubscription" :loading="savingSubscription"
:subscribed="store.subscription" :subscribed="store.subscribed"
@toggleSubscription="handleToggleSubscription" @toggleSubscription="handleToggleSubscribed"
@toggleCollapse="toggleSidebar" @toggleCollapse="toggleSidebar"
/> />
</div> </div>
......
...@@ -14,7 +14,7 @@ export default class SidebarService { ...@@ -14,7 +14,7 @@ export default class SidebarService {
return axios.put(this.endpoint, { end_date: endDate }); return axios.put(this.endpoint, { end_date: endDate });
} }
toggleSubscription() { toggleSubscribed() {
return axios.post(this.subscriptionEndpoint); return axios.post(this.subscriptionEndpoint);
} }
} }
...@@ -15,11 +15,7 @@ export default class SidebarStore { ...@@ -15,11 +15,7 @@ export default class SidebarStore {
return this.endDate ? parsePikadayDate(this.endDate) : null; return this.endDate ? parsePikadayDate(this.endDate) : null;
} }
get subscription() { setSubscribed(subscribed) {
return this.subscribed;
}
setSubscription(subscribed) {
this.subscribed = subscribed; this.subscribed = subscribed;
} }
} }
...@@ -54,4 +54,13 @@ describe('Sidebar Store', () => { ...@@ -54,4 +54,13 @@ describe('Sidebar Store', () => {
expect(date.getFullYear()).toEqual(2017); expect(date.getFullYear()).toEqual(2017);
}); });
}); });
describe('setSubscribed', () => {
it('should set store.subscribed value', () => {
const store = new SidebarStore({ subscribed: true });
store.setSubscribed(false);
expect(store.subscribed).toEqual(false);
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment