Skip to content

Commit

Permalink
Handle possibly undefined response fields
Browse files Browse the repository at this point in the history
These are both number | undefined, so we default to 0 if we need a
value. Fixes the type errors resulting from the previous type changes.
  • Loading branch information
rylnd committed Aug 10, 2021
1 parent f996e0b commit 8bb736c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export const useStatusBulkActionItems = ({
// TODO: Only delete those that were successfully updated from updatedRules
setEventsDeleted({ eventIds, isDeleted: true });

if (response.version_conflicts > 0 && eventIds.length === 1) {
if (response.version_conflicts && eventIds.length === 1) {
throw new Error(i18n.BULK_ACTION_FAILED_SINGLE_ALERT);
}

onUpdateSuccess(response.updated, response.version_conflicts, status);
onUpdateSuccess(response.updated ?? 0, response.version_conflicts ?? 0, status);
} catch (error) {
onUpdateFailure(status, error);
} finally {
Expand Down

0 comments on commit 8bb736c

Please sign in to comment.