From 658a2bd3cd4c32cfa0d2ea1aa89ff6e71c5eef07 Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Wed, 8 Jan 2020 14:07:50 +0100 Subject: [PATCH 1/2] Remove empty object from parameter list --- scm-ui/ui-components/src/repos/Diff.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-ui/ui-components/src/repos/Diff.stories.tsx b/scm-ui/ui-components/src/repos/Diff.stories.tsx index 09ef48c0b5..8e5260bcc5 100644 --- a/scm-ui/ui-components/src/repos/Diff.stories.tsx +++ b/scm-ui/ui-components/src/repos/Diff.stories.tsx @@ -33,7 +33,7 @@ storiesOf("Diff", module) /> )) .add("OnClick", () => { - const OnClickDemo = ({}) => { + const OnClickDemo = () => { const [changeId, setChangeId] = useState(); useEffect(() => { const interval = setInterval(() => setChangeId(undefined), 2000); From 67777ff52d8bd7e2e599812daf25e5e96f2b6d57 Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Wed, 8 Jan 2020 16:42:07 +0100 Subject: [PATCH 2/2] Fix reduce error with empty diff --- scm-ui/ui-components/src/repos/DiffFile.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scm-ui/ui-components/src/repos/DiffFile.tsx b/scm-ui/ui-components/src/repos/DiffFile.tsx index fe35cc111f..942d789f99 100644 --- a/scm-ui/ui-components/src/repos/DiffFile.tsx +++ b/scm-ui/ui-components/src/repos/DiffFile.tsx @@ -222,6 +222,14 @@ class DiffFile extends React.Component { return ; }; + concat = (array: object[][]) => { + if (array.length > 0) { + return array.reduce((a, b) => a.concat(b)); + } else { + return []; + } + }; + render() { const { file, fileControlFactory, fileAnnotationFactory, t } = this.props; const { collapsed, sideBySide } = this.state; @@ -236,7 +244,7 @@ class DiffFile extends React.Component {
{fileAnnotations} - {(hunks: HunkType[]) => hunks.map(this.renderHunk).reduce((a, b) => a.concat(b))} + {(hunks: HunkType[]) => this.concat(hunks.map(this.renderHunk))}
);