store id with certifiers
This commit is contained in:
parent
3dc943e854
commit
fd88421e88
@ -53,7 +53,7 @@ export default class BadgeReg {
|
||||
name = name === ZERO32 ? null : hex2Ascii(name);
|
||||
return this.fetchMeta(id)
|
||||
.then(({ title, icon }) => {
|
||||
const data = { address, name, title, icon };
|
||||
const data = { address, id, name, title, icon };
|
||||
this.certifiers[id] = data;
|
||||
return data;
|
||||
});
|
||||
|
@ -22,6 +22,10 @@ export const fetchCertifications = (address) => ({
|
||||
type: 'fetchCertifications', address
|
||||
});
|
||||
|
||||
export const addCertification = (address, name, title, icon) => ({
|
||||
type: 'addCertification', address, name, title, icon
|
||||
export const addCertification = (address, id, name, title, icon) => ({
|
||||
type: 'addCertification', address, id, name, title, icon
|
||||
});
|
||||
|
||||
export const removeCertification = (address, id, name, title, icon) => ({
|
||||
type: 'removeCertification', address, id, name, title, icon
|
||||
});
|
||||
|
@ -44,8 +44,8 @@ export default class CertificationsMiddleware {
|
||||
logs.forEach((log) => {
|
||||
const certifier = certifiers.find((c) => c.address === log.address);
|
||||
if (!certifier) throw new Error(`Could not find certifier at ${log.address}.`);
|
||||
const { name, title, icon } = certifier;
|
||||
dispatch(addCertification(log.params.who.value, name, title, icon));
|
||||
const { id, name, title, icon } = certifier;
|
||||
dispatch(addCertification(log.params.who.value, id, name, title, icon));
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -59,7 +59,7 @@ export default class CertificationsMiddleware {
|
||||
new Array(+count).fill(null).forEach((_, id) => {
|
||||
badgeReg.fetchCertifier(id)
|
||||
.then((cert) => {
|
||||
if (!certifiers.some((c) => c.address === cert.address)) {
|
||||
if (!certifiers.some((c) => c.id === cert.id)) {
|
||||
certifiers = certifiers.concat(cert);
|
||||
fetchConfirmedEvents(store.dispatch);
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ export default (state = initialState, action) => {
|
||||
return state;
|
||||
}
|
||||
|
||||
const { address, name, icon, title } = action;
|
||||
const { address, id, name, icon, title } = action;
|
||||
const certifications = state[address] || [];
|
||||
|
||||
if (certifications.some((c) => c.name === name)) {
|
||||
if (certifications.some((c) => c.id === id)) {
|
||||
return state;
|
||||
}
|
||||
const newCertifications = certifications.concat({ name, icon, title });
|
||||
const newCertifications = certifications.concat({ id, name, icon, title });
|
||||
|
||||
return { ...state, [address]: newCertifications };
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user