reverse caching: PR grumbles

This commit is contained in:
Jannis R 2017-01-09 17:49:01 +01:00
parent 61a42cc7e4
commit cca7627fb8
No known key found for this signature in database
GPG Key ID: 0FE83946296A88A5
2 changed files with 6 additions and 5 deletions

View File

@ -20,6 +20,10 @@ const initialState = {
export default (state = initialState, action) => {
if (action.type === 'setReverse') {
if (state.reverse[action.address] === action.reverse) {
return state;
}
return { ...state, reverse: {
...state.reverse, [ action.address ]: action.reverse
} };

View File

@ -36,6 +36,7 @@ export default class AddressSelectStore {
if (query.length === 0 || query === '0x') {
return null;
}
const startsWithQuery = (s) => new RegExp('^' + query, 'i').test(s);
let address;
let name = this.reverse[query];
@ -44,12 +45,8 @@ export default class AddressSelectStore {
const addr = Object
.keys(this.reverse)
.find((addr) => {
if (addr.toLowerCase().slice(0, query.length) === query) {
return true;
}
const name = this.reverse[addr];
return name.toLowerCase().slice(0, query.length) === query;
return startsWithQuery(addr) || (name && startsWithQuery(name));
});
if (addr) {