Skip to content

Commit 1086e7c

Browse files
committed
clear history has landed
1 parent 9b7a9c5 commit 1086e7c

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/client/components/containers/HistoryContainer.jsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import React, { Component } from 'react';
22
import { connect } from 'react-redux';
33
import * as actions from '../../actions/actions';
44
import HistoryDate from '../display/HistoryDate.jsx';
5+
import ClearHistoryBtn from '../display/ClearHistoryBtn.jsx';
56
import historyController from '../../controllers/historyController';
7+
68
const { dialog } = require('electron').remote;
79
import parse from 'date-fns/parse'
810

@@ -46,20 +48,7 @@ class HistoryContainer extends Component {
4648
<div className={'historyDate-container'}>
4749
<h1>History</h1>
4850
<div className="clear-history">
49-
<button onClick={() => {
50-
const opts = {
51-
type: 'warning',
52-
buttons: ['Okay', 'Cancel'],
53-
message: 'Are you sure you want to clear history?'
54-
}
55-
56-
dialog.showMessageBox(null, opts, (response) => {
57-
if (response === 0) {
58-
this.props.clearHistory();
59-
historyController.clearHistoryFromIndexedDb();
60-
}
61-
})
62-
}}>Clear History</button>
51+
<ClearHistoryBtn clearHistory={this.props.clearHistory} />
6352
</div>
6453
{historyDates}
6554
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import historyController from '../../controllers/historyController';
3+
const { dialog } = require('electron').remote;
4+
5+
const ClearHistoryBtn = (props) => (
6+
<button onClick={() => {
7+
const opts = {
8+
type: 'warning',
9+
buttons: ['Okay', 'Cancel'],
10+
message: 'Are you sure you want to clear history?'
11+
}
12+
13+
dialog.showMessageBox(null, opts, (response) => {
14+
if (response === 0) {
15+
props.clearHistory();
16+
historyController.clearHistoryFromIndexedDb();
17+
}
18+
})
19+
}}>Clear History</button>
20+
)
21+
22+
export default ClearHistoryBtn;

0 commit comments

Comments
 (0)