Errors: append in bulk rather than 1 by 1.
parent
06e4e4a5d3
commit
d4ca0a3ec4
|
@ -13,6 +13,7 @@ export function syncEntriesToItemMap(
|
|||
collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>, base: {[key: string]: ContactType} = {}) {
|
||||
const items = base;
|
||||
|
||||
const errors: Error[] = [];
|
||||
entries.forEach((syncEntry) => {
|
||||
// FIXME: this is a terrible hack to handle parsing errors
|
||||
let comp;
|
||||
|
@ -20,7 +21,7 @@ export function syncEntriesToItemMap(
|
|||
comp = ContactType.parse(syncEntry.content);
|
||||
} catch (e) {
|
||||
e.message = `${e.message}\nWhile processing: ${syncEntry.content}`;
|
||||
store.dispatch(appendError(undefined as any, e));
|
||||
errors.push(e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -36,6 +37,10 @@ export function syncEntriesToItemMap(
|
|||
}
|
||||
});
|
||||
|
||||
if (errors.length > 0) {
|
||||
store.dispatch(appendError(undefined as any, errors));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -87,6 +92,7 @@ function syncEntriesToCalendarItemMap<T extends EventType>(
|
|||
|
||||
const color = colorIntToHtml(collection.color);
|
||||
|
||||
const errors: Error[] = [];
|
||||
entries.forEach((syncEntry) => {
|
||||
// FIXME: this is a terrible hack to handle parsing errors
|
||||
let comp;
|
||||
|
@ -94,7 +100,7 @@ function syncEntriesToCalendarItemMap<T extends EventType>(
|
|||
comp = ItemType.parse(syncEntry.content);
|
||||
} catch (e) {
|
||||
e.message = `${e.message}\nWhile processing: ${syncEntry.content}`;
|
||||
store.dispatch(appendError(undefined as any, e));
|
||||
errors.push(e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,6 +122,10 @@ function syncEntriesToCalendarItemMap<T extends EventType>(
|
|||
}
|
||||
});
|
||||
|
||||
if (errors.length > 0) {
|
||||
store.dispatch(appendError(undefined as any, errors));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
|
|
@ -198,8 +198,8 @@ export function fetchAll(etesync: CredentialsData, currentEntries: EntriesData)
|
|||
|
||||
export const appendError = createAction(
|
||||
'APPEND_ERROR',
|
||||
(_etesync: CredentialsData, error: Error) => {
|
||||
return error;
|
||||
(_etesync: CredentialsData, error: Error | Error[]) => {
|
||||
return Array.isArray(error) ? error : [error];
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ export const errorsReducer = handleActions(
|
|||
return state;
|
||||
},
|
||||
[actions.appendError.toString()]: (state: List<Error>, action: Action<any>) => {
|
||||
return state.push(action.payload);
|
||||
return state.push(...action.payload);
|
||||
},
|
||||
[actions.clearErros.toString()]: (state: List<Error>, _action: Action<any>) => {
|
||||
return state.clear();
|
||||
|
|
Loading…
Reference in New Issue