Fix issue with different items across collections sharing the same uid

The existing code falsely (and accidentally) assumed that all items
(even across different collections) will have unique uids. This is a
false assumption, especially when importing one collection into the
other.
master
Tom Hacohen 5 years ago
parent e85d611aa6
commit c0c5af0cab

@ -50,7 +50,7 @@ export function journalView(JournalList: any, JournalItem: any) {
render={({match}) => { render={({match}) => {
return ( return (
<JournalItem item={items[match.params.itemUid]} /> <JournalItem item={items[`${match.params.journalUid}|${match.params.itemUid}`]} />
); );
}} }}
/> />

@ -52,24 +52,27 @@ class PimMain extends React.PureComponent<PropsType> {
} }
public eventClicked(event: ICAL.Event) { public eventClicked(event: ICAL.Event) {
const uid = event.uid; // FIXME:Hack
const itemUid = `${(event as any).journalUid}|${event.uid}`;
this.props.history!.push( this.props.history!.push(
routeResolver.getRoute('pim.events._id', { itemUid: uid })); routeResolver.getRoute('pim.events._id', { itemUid }));
} }
public taskClicked(event: ICAL.Event) { public taskClicked(event: ICAL.Event) {
const uid = event.uid; // FIXME:Hack
const itemUid = `${(event as any).journalUid}|${event.uid}`;
this.props.history!.push( this.props.history!.push(
routeResolver.getRoute('pim.tasks._id', { itemUid: uid })); routeResolver.getRoute('pim.tasks._id', { itemUid }));
} }
public contactClicked(contact: ContactType) { public contactClicked(contact: ContactType) {
const uid = contact.uid; // FIXME:Hack
const itemUid = `${(contact as any).journalUid}|${contact.uid}`;
this.props.history!.push( this.props.history!.push(
routeResolver.getRoute('pim.contacts._id', { itemUid: uid })); routeResolver.getRoute('pim.contacts._id', { itemUid }));
} }
public newEvent(start?: Date, end?: Date) { public newEvent(start?: Date, end?: Date) {

@ -81,11 +81,13 @@ const itemsSelector = createSelector(
const ItemChangeLog = pure((props: any) => { const ItemChangeLog = pure((props: any) => {
const { const {
syncInfo, syncInfo,
items, paramItemUid,
uid,
} = props; } = props;
const journalItem = syncInfo.get(items[uid].journalUid); const tmp = paramItemUid.split('|');
const journalUid = tmp.shift();
const uid = tmp.join('|');
const journalItem = syncInfo.get(journalUid);
return ( return (
<React.Fragment> <React.Fragment>
@ -169,8 +171,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
<Container> <Container>
<ItemChangeLog <ItemChangeLog
syncInfo={props.syncInfo} syncInfo={props.syncInfo}
items={props.items} paramItemUid={match.params.itemUid}
uid={match.params.itemUid}
/> />
</Container> </Container>
)} )}

@ -13,10 +13,9 @@ export function syncEntriesToItemMap(
entries.forEach((syncEntry) => { entries.forEach((syncEntry) => {
const comp = new ContactType(new ICAL.Component(ICAL.parse(syncEntry.content))); const comp = new ContactType(new ICAL.Component(ICAL.parse(syncEntry.content)));
const uid = comp.uid;
// FIXME:Hack // FIXME:Hack
(comp as any).journalUid = collection.uid; (comp as any).journalUid = collection.uid;
const uid = `${collection.uid}|${comp.uid}`;
if ((syncEntry.action === EteSync.SyncEntryAction.Add) || if ((syncEntry.action === EteSync.SyncEntryAction.Add) ||
(syncEntry.action === EteSync.SyncEntryAction.Change)) { (syncEntry.action === EteSync.SyncEntryAction.Change)) {
@ -66,10 +65,9 @@ function syncEntriesToCalendarItemMap<T extends EventType>(
comp.color = color; comp.color = color;
const uid = comp.uid;
// FIXME:Hack // FIXME:Hack
(comp as any).journalUid = collection.uid; (comp as any).journalUid = collection.uid;
const uid = `${collection.uid}|${comp.uid}`;
if ((syncEntry.action === EteSync.SyncEntryAction.Add) || if ((syncEntry.action === EteSync.SyncEntryAction.Add) ||
(syncEntry.action === EteSync.SyncEntryAction.Change)) { (syncEntry.action === EteSync.SyncEntryAction.Change)) {

Loading…
Cancel
Save