1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-26 18:58:21 +02:00

Update following review.

Modify message to remove need for translation.
Flatten properties structure.
This commit is contained in:
mic074b 2020-01-24 19:23:01 +11:00
parent f661cad6a3
commit d8f91a2ece
2 changed files with 15 additions and 26 deletions

View File

@ -116,22 +116,12 @@ class NoteSearchBarComponent extends React.Component {
this.refs.searchInput.focus();
}
getMatchesFoundString() {
if (this.props.resultCount === 0) {
return _('No matches found');
}
if (this.props.resultCount === 1) {
return _('1 of 1 match');
}
return _('%d of %d matches', this.props.selectedIndex + 1, this.props.resultCount);
}
render() {
const theme = themeStyle(this.props.theme);
let backgroundColor = theme.backgroundColor;
let buttonEnabled = true;
if (this.props.resultCount === 0 && this.props.query.length > 0) {
if (this.props.resultCount === 0 && this.props.resultQuery.length > 0) {
backgroundColor = theme.warningBackgroundColor;
buttonEnabled = false;
}
@ -146,10 +136,10 @@ class NoteSearchBarComponent extends React.Component {
color: theme.colorFaded,
backgroundColor: theme.backgroundColor,
});
const matchesFoundString = (this.props.query.length > 0) ? (
<div style={textStyle}> {
this.getMatchesFoundString()
} </div>
const matchesFoundString = (this.props.resultQuery.length > 0 && this.props.resultCount > 0) ? (
<div style={textStyle}>
{`${this.props.selectedIndex + 1} / ${this.props.resultCount}`}
</div>
) : null;
return (

View File

@ -89,7 +89,8 @@ class NoteTextComponent extends React.Component {
this.localSearchDefaultState = {
query: '',
selectedIndex: 0,
result: { query: '', count: 0 },
resultQuery: '',
resultCount: 0,
};
this.state = {
@ -312,10 +313,8 @@ class NoteTextComponent extends React.Component {
query: query,
selectedIndex: 0,
timestamp: Date.now(),
result: {
query: this.state.localSearch.result.query,
count: this.state.localSearch.result.count,
},
resultQuery: this.state.localSearch.resultQuery,
resultCount: this.state.localSearch.resultCount,
},
});
};
@ -324,8 +323,8 @@ class NoteTextComponent extends React.Component {
const ls = Object.assign({}, this.state.localSearch);
ls.selectedIndex += inc;
ls.timestamp = Date.now();
if (ls.selectedIndex < 0) ls.selectedIndex = ls.result.count - 1;
if (ls.selectedIndex >= ls.result.count) ls.selectedIndex = 0;
if (ls.selectedIndex < 0) ls.selectedIndex = ls.resultCount - 1;
if (ls.selectedIndex >= ls.resultCount) ls.selectedIndex = 0;
this.setState({ localSearch: ls });
};
@ -768,8 +767,8 @@ class NoteTextComponent extends React.Component {
reg.logger().error(s.join(':'));
} else if (msg === 'setMarkerCount') {
const ls = Object.assign({}, this.state.localSearch);
ls.result.query = ls.query;
ls.result.count = arg0;
ls.resultQuery = ls.query;
ls.resultCount = arg0;
this.setState({ localSearch: ls });
} else if (msg.indexOf('markForDownload:') === 0) {
const s = msg.split(':');
@ -2155,8 +2154,8 @@ class NoteTextComponent extends React.Component {
width: innerWidth,
borderTop: `1px solid ${theme.dividerColor}`,
}}
query={this.state.localSearch.result.query}
resultCount={this.state.localSearch.result.count}
resultQuery={this.state.localSearch.resultQuery}
resultCount={this.state.localSearch.resultCount}
selectedIndex={this.state.localSearch.selectedIndex}
onChange={this.noteSearchBar_change}
onNext={this.noteSearchBar_next}