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}) => {
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) {
const uid = event.uid;
// FIXME:Hack
const itemUid = `${(event as any).journalUid}|${event.uid}`;
this.props.history!.push(
routeResolver.getRoute('pim.events._id', { itemUid: uid }));
routeResolver.getRoute('pim.events._id', { itemUid }));
}
public taskClicked(event: ICAL.Event) {
const uid = event.uid;
// FIXME:Hack
const itemUid = `${(event as any).journalUid}|${event.uid}`;
this.props.history!.push(
routeResolver.getRoute('pim.tasks._id', { itemUid: uid }));
routeResolver.getRoute('pim.tasks._id', { itemUid }));
}
public contactClicked(contact: ContactType) {
const uid = contact.uid;
// FIXME:Hack
const itemUid = `${(contact as any).journalUid}|${contact.uid}`;
this.props.history!.push(
routeResolver.getRoute('pim.contacts._id', { itemUid: uid }));
routeResolver.getRoute('pim.contacts._id', { itemUid }));
}
public newEvent(start?: Date, end?: Date) {

@ -81,11 +81,13 @@ const itemsSelector = createSelector(
const ItemChangeLog = pure((props: any) => {
const {
syncInfo,
items,
uid,
paramItemUid,
} = 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 (
<React.Fragment>
@ -169,8 +171,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
<Container>
<ItemChangeLog
syncInfo={props.syncInfo}
items={props.items}
uid={match.params.itemUid}
paramItemUid={match.params.itemUid}
/>
</Container>
)}

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

Loading…
Cancel
Save