reverse caching: PR grumbles
This commit is contained in:
parent
61a42cc7e4
commit
cca7627fb8
@ -20,6 +20,10 @@ const initialState = {
|
|||||||
|
|
||||||
export default (state = initialState, action) => {
|
export default (state = initialState, action) => {
|
||||||
if (action.type === 'setReverse') {
|
if (action.type === 'setReverse') {
|
||||||
|
if (state.reverse[action.address] === action.reverse) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
return { ...state, reverse: {
|
return { ...state, reverse: {
|
||||||
...state.reverse, [ action.address ]: action.reverse
|
...state.reverse, [ action.address ]: action.reverse
|
||||||
} };
|
} };
|
||||||
|
@ -36,6 +36,7 @@ export default class AddressSelectStore {
|
|||||||
if (query.length === 0 || query === '0x') {
|
if (query.length === 0 || query === '0x') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const startsWithQuery = (s) => new RegExp('^' + query, 'i').test(s);
|
||||||
|
|
||||||
let address;
|
let address;
|
||||||
let name = this.reverse[query];
|
let name = this.reverse[query];
|
||||||
@ -44,12 +45,8 @@ export default class AddressSelectStore {
|
|||||||
const addr = Object
|
const addr = Object
|
||||||
.keys(this.reverse)
|
.keys(this.reverse)
|
||||||
.find((addr) => {
|
.find((addr) => {
|
||||||
if (addr.toLowerCase().slice(0, query.length) === query) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = this.reverse[addr];
|
const name = this.reverse[addr];
|
||||||
return name.toLowerCase().slice(0, query.length) === query;
|
return startsWithQuery(addr) || (name && startsWithQuery(name));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (addr) {
|
if (addr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user