...
 
Commits (2)
......@@ -31,9 +31,7 @@ export default
@observer
class ChannelActions extends Component {
state = {
scheduledCount: '',
}
state = {}
componentDidMount() {
this.getScheduledCount();
......@@ -112,8 +110,7 @@ class ChannelActions extends Component {
getScheduledCount = async () => {
if (featuresService.has('post-scheduler')) {
const count = await this.props.store.feedStore.getScheduledCount();
this.setState({ scheduledCount: count });
await this.props.store.feedStore.getScheduledCount();
}
}
......@@ -149,7 +146,7 @@ class ChannelActions extends Component {
<ButtonCustom
onPress={this.onViewScheduledAction}
accessibilityLabel={i18n.t('channel.viewScheduled')}
text={`${i18n.t('channel.viewScheduled')}: ${this.state.scheduledCount}`}
text={`${i18n.t('channel.viewScheduled')}: ${this.props.store.feedStore.feedStore.scheduledCount}`}
loading={this.state.saving}
inverted={this.props.store.feedStore.endpoint == this.props.store.feedStore.scheduledEndpoint ? true : undefined}
/>
......
......@@ -3,7 +3,6 @@ import {
action,
} from 'mobx'
import channelService from './ChannelService';
import FeedStore from '../common/stores/FeedStore';
/**
......@@ -87,16 +86,7 @@ export default class ChannelFeedStore {
* Get channel scheduled activities count
*/
async getScheduledCount() {
const count = await channelService.getScheduledCount(this.guid);
return count;
}
/**
* Get channel scheduled activities count
*/
async getScheduledCount() {
const count = await channelService.getScheduledCount(this.guid);
return count;
await this.feedStore.getScheduledCount(this.guid);
}
@action
......
......@@ -5,12 +5,15 @@ import Viewed from './Viewed';
import MetadataService from '../services/metadata.service';
import FeedsService from '../services/feeds.service';
import connectivityService from '../services/connectivity.service';
import channelService from '../../channel/ChannelService';
/**
* Feed store
*/
export default class FeedStore {
@observable scheduledCount = '';
/**
* Refreshing
*/
......@@ -143,6 +146,9 @@ export default class FeedStore {
entity._list = this;
this.entities.unshift(entity);
this.feedsService.prepend(entity);
if (entity.isScheduled()) {
this.setScheduledCount(this.scheduledCount + 1);
}
}
/**
......@@ -162,6 +168,9 @@ export default class FeedStore {
const index = this.entities.findIndex(e => e === entity);
if (index < 0) return;
this.removeIndex(index);
if (entity.isScheduled()) {
this.setScheduledCount(this.scheduledCount - 1);
}
}
/**
......@@ -423,4 +432,17 @@ export default class FeedStore {
this.feedsService.setOffset(0);
return this;
}
/**
* Get channel scheduled activities count
*/
async getScheduledCount(guid) {
const count = await channelService.getScheduledCount(guid);
this.setScheduledCount(count);
}
@action
setScheduledCount(count) {
this.scheduledCount = count;
}
}