This repository was archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 970
/
Copy pathadblock.js
56 lines (51 loc) · 1.85 KB
/
adblock.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Note that these are webpack requires, not CommonJS node requiring requires
const React = require('react')
const Immutable = require('immutable')
const messages = require('../constants/messages')
const ipc = window.chrome.ipc
// Stylesheets
require('../../less/about/itemList.less')
require('../../less/about/adblock.less')
class AboutAdBlock extends React.Component {
constructor () {
super()
this.state = {
adblock: Immutable.Map()
}
ipc.on(messages.ADBLOCK_UPDATED, (e, detail) => {
if (!detail) {
return
}
this.setState({
adblock: Immutable.fromJS(detail.adblock)
})
})
}
render () {
const lastUpdateDate = new Date(this.state.adblock.get('lastCheckDate'))
return <div className='adblockDetailsPage'>
<h2 data-l10n-id='adblock' />
<list>
<div role='listitem'>
<div className='adblockDetailsPageContent'>
<div className='adblockCount'><span data-l10n-id='blockedCountLabel' /> <span className='blockedCountTotal'>{this.state.adblock.get('count') || 0}</span></div>
{
Number.isNaN(lastUpdateDate.getTime())
? null
: <div className='adblockLastChecked'><span data-l10n-id='lastUpdateCheckDateLabel' /> <span>{lastUpdateDate.toLocaleDateString()}</span></div>
}
{
this.state.adblock.get('etag')
? <div className='adblockLastETag'><span data-l10n-id='lastCheckETagLabel' /> <span>{this.state.adblock.get('etag')}</span></div>
: null
}
</div>
</div>
</list>
</div>
}
}
module.exports = <AboutAdBlock />