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 @@
this.toggleSidebar();
}
},
handleToggleSubscription() {
this.service.toggleSubscription()
handleToggleSubscribed() {
this.service.toggleSubscribed()
.then(() => {
this.store.setSubscription(!this.store.subscription);
this.store.setSubscribed(!this.store.subscribed);
})
.catch(() => {
if (this.store.subscription) {
if (this.store.subscribed) {
Flash(__('An error occurred while unsubscribing to notifications.'));
} else {
Flash(__('An error occurred while subscribing to notifications.'));
......@@ -260,8 +260,8 @@
/>
<sidebar-subscriptions
:loading="savingSubscription"
:subscribed="store.subscription"
@toggleSubscription="handleToggleSubscription"
:subscribed="store.subscribed"
@toggleSubscription="handleToggleSubscribed"
@toggleCollapse="toggleSidebar"
/>
</div>
......
......@@ -14,7 +14,7 @@ export default class SidebarService {
return axios.put(this.endpoint, { end_date: endDate });
}
toggleSubscription() {
toggleSubscribed() {
return axios.post(this.subscriptionEndpoint);
}
}
......@@ -15,11 +15,7 @@ export default class SidebarStore {
return this.endDate ? parsePikadayDate(this.endDate) : null;
}
get subscription() {
return this.subscribed;
}
setSubscription(subscribed) {
setSubscribed(subscribed) {
this.subscribed = subscribed;
}
}
......@@ -54,4 +54,13 @@ describe('Sidebar Store', () => {
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