feat(p2p): information about feed

This commit is contained in:
Alexey Kasyanchuk 2018-07-18 11:33:25 +03:00
parent 8792da82d5
commit bd8921c186
2 changed files with 31 additions and 27 deletions

View File

@ -16,12 +16,12 @@ export default class ConfigPage extends Page {
this.setTitle('Rats filters'); this.setTitle('Rats filters');
this.options = {} this.options = {}
this.basicTypes = ['video', this.basicTypes = ['video',
'audio', 'audio',
'pictures', 'pictures',
'books', 'books',
'application', 'application',
'archive', 'archive',
'disc'] 'disc']
this.contentType = this.basicTypes.slice(0) this.contentType = this.basicTypes.slice(0)
this.descriptions = { this.descriptions = {
main: __('All'), main: __('All'),
@ -190,28 +190,28 @@ export default class ConfigPage extends Page {
} }
<div className='column w100p'> <div className='column w100p'>
<div style={{flex: 1, padding: '8px 0px'}}>{__('disable some categories')}:</div> <div style={{flex: 1, padding: '8px 0px'}}>{__('disable some categories')}:</div>
{ {
this.basicTypes.map(type => (<Checkbox this.basicTypes.map(type => (<Checkbox
label={this.descriptions[type]} label={this.descriptions[type]}
checked={this.contentType && this.contentType.indexOf(type) >= 0} checked={this.contentType && this.contentType.indexOf(type) >= 0}
onCheck={e => { onCheck={e => {
if(e.target.checked) if(e.target.checked)
{ {
this.contentType.push(type) this.contentType.push(type)
} }
else else
{ {
const index = this.contentType.indexOf(type) const index = this.contentType.indexOf(type)
this.contentType.splice(index, 1) this.contentType.splice(index, 1)
} }
if(this.contentType.length == 0) if(this.contentType.length == 0)
this.contentType = this.basicTypes.slice(0) this.contentType = this.basicTypes.slice(0)
this.forceUpdate() this.forceUpdate()
}} }}
/>)) />))
} }
</div> </div>
{ {

View File

@ -891,6 +891,10 @@ module.exports = async ({
// store torrent to feed // store torrent to feed
await feed.load() await feed.load()
Object.defineProperty(p2p.info, 'feed', {
enumerable: true,
get: () => feed.size()
});
p2pStore.on('store', async ({data: record, temp, myself}) => { p2pStore.on('store', async ({data: record, temp, myself}) => {
if(record.type !== 'vote') if(record.type !== 'vote')
return return