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