Commit f32ec46e authored by Tim Zallmann's avatar Tim Zallmann

Fix for a check that fails if no file can be selected

parent 1be03eaa
...@@ -86,62 +86,66 @@ export default { ...@@ -86,62 +86,66 @@ export default {
[types.SET_LINE_DISCUSSIONS_FOR_FILE](state, { fileHash, discussions }) { [types.SET_LINE_DISCUSSIONS_FOR_FILE](state, { fileHash, discussions }) {
const selectedFile = state.diffFiles.find(f => f.fileHash === fileHash); const selectedFile = state.diffFiles.find(f => f.fileHash === fileHash);
const firstDiscussion = discussions[0]; if (selectedFile) {
const targetLine = selectedFile.parallelDiffLines.find( const firstDiscussion = discussions[0];
line => const targetLine = selectedFile.parallelDiffLines.find(
(line.left && line.left.lineCode === firstDiscussion.line_code) || line =>
(line.right && line.right.lineCode === firstDiscussion.line_code), (line.left && line.left.lineCode === firstDiscussion.line_code) ||
); (line.right && line.right.lineCode === firstDiscussion.line_code),
if (targetLine) { );
if (targetLine.left && targetLine.left.lineCode === firstDiscussion.line_code) { if (targetLine) {
Object.assign(targetLine.left, { if (targetLine.left && targetLine.left.lineCode === firstDiscussion.line_code) {
discussions, Object.assign(targetLine.left, {
}); discussions,
} else { });
Object.assign(targetLine.right, { } else {
discussions, Object.assign(targetLine.right, {
}); discussions,
});
}
} }
}
if (selectedFile.highlightedDiffLines) { if (selectedFile.highlightedDiffLines) {
const targetInlineLine = selectedFile.highlightedDiffLines.find( const targetInlineLine = selectedFile.highlightedDiffLines.find(
line => line.lineCode === firstDiscussion.line_code, line => line.lineCode === firstDiscussion.line_code,
); );
if (targetInlineLine) { if (targetInlineLine) {
Object.assign(targetInlineLine, { Object.assign(targetInlineLine, {
discussions, discussions,
}); });
}
} }
} }
}, },
[types.REMOVE_LINE_DISCUSSIONS_FOR_FILE](state, { fileHash, lineCode }) { [types.REMOVE_LINE_DISCUSSIONS_FOR_FILE](state, { fileHash, lineCode }) {
const selectedFile = state.diffFiles.find(f => f.fileHash === fileHash); const selectedFile = state.diffFiles.find(f => f.fileHash === fileHash);
const targetLine = selectedFile.parallelDiffLines.find( if (selectedFile) {
line => const targetLine = selectedFile.parallelDiffLines.find(
(line.left && line.left.lineCode === lineCode) || line =>
(line.right && line.right.lineCode === lineCode), (line.left && line.left.lineCode === lineCode) ||
); (line.right && line.right.lineCode === lineCode),
if (targetLine) {
const side = targetLine.left && targetLine.left.lineCode === lineCode ? 'left' : 'right';
Object.assign(targetLine[side], {
discussions: [],
});
}
if (selectedFile.highlightedDiffLines) {
const targetInlineLine = selectedFile.highlightedDiffLines.find(
line => line.lineCode === lineCode,
); );
if (targetLine) {
const side = targetLine.left && targetLine.left.lineCode === lineCode ? 'left' : 'right';
if (targetInlineLine) { Object.assign(targetLine[side], {
Object.assign(targetInlineLine, {
discussions: [], discussions: [],
}); });
} }
if (selectedFile.highlightedDiffLines) {
const targetInlineLine = selectedFile.highlightedDiffLines.find(
line => line.lineCode === lineCode,
);
if (targetInlineLine) {
Object.assign(targetInlineLine, {
discussions: [],
});
}
}
} }
}, },
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment