Remove diff summary from document history sidebar.

Cause of occassional memory leaks and downtime :(
This commit is contained in:
Tom Moor
2018-11-23 11:12:14 -08:00
parent 36fd81d190
commit 67cd250316
7 changed files with 4 additions and 97 deletions

View File

@@ -82,12 +82,6 @@ class DocumentHistory extends React.Component<Props> {
render() {
const showLoading = !this.isLoaded && this.isFetching;
const maxChanges = this.revisions.reduce((acc, change) => {
if (acc < change.diff.added + change.diff.removed) {
return change.diff.added + change.diff.removed;
}
return acc;
}, 0);
return (
<Wrapper column>
@@ -105,7 +99,6 @@ class DocumentHistory extends React.Component<Props> {
key={revision.id}
revision={revision}
document={this.props.document}
maxChanges={maxChanges}
showMenu={index !== 0}
/>
))}

View File

@@ -1,58 +0,0 @@
// @flow
import * as React from 'react';
import styled from 'styled-components';
import Flex from 'shared/components/Flex';
type Props = {
added: number,
removed: number,
max: number,
color?: string,
width: number,
};
export default function DiffSummary({
added,
removed,
max,
color,
width = 180,
}: Props) {
const summary = [];
if (added) summary.push(`+${added}`);
if (removed) summary.push(`-${removed}`);
const hasChanges = !!summary.length;
return (
<Flex align="center">
{hasChanges && (
<Diff>
<Bar color={color} style={{ width: `${added / max * width}px` }} />
<Bar color={color} style={{ width: `${removed / max * width}px` }} />
</Diff>
)}
<Summary>{hasChanges ? summary.join(', ') : 'No changes'}</Summary>
</Flex>
);
}
const Summary = styled.div`
display: inline-block;
font-size: 10px;
opacity: 0.5;
flex-grow: 100;
text-transform: uppercase;
`;
const Diff = styled(Flex)`
height: 6px;
margin-right: 2px;
`;
const Bar = styled.div`
display: inline-block;
background: ${props => props.color || props.theme.text};
height: 100%;
opacity: 0.3;
margin-right: 1px;
`;

View File

@@ -9,13 +9,12 @@ import Flex from 'shared/components/Flex';
import Time from 'shared/components/Time';
import Avatar from 'components/Avatar';
import RevisionMenu from 'menus/RevisionMenu';
import DiffSummary from './DiffSummary';
import { documentHistoryUrl } from 'utils/routeHelpers';
class Revision extends React.Component<*> {
render() {
const { revision, document, maxChanges, showMenu, theme } = this.props;
const { revision, document, showMenu, theme } = this.props;
return (
<StyledNavLink
@@ -31,7 +30,6 @@ class Revision extends React.Component<*> {
{format(revision.createdAt, 'MMMM Do, YYYY h:mm a')}
</Time>
</Meta>
<DiffSummary {...revision.diff} max={maxChanges} />
{showMenu && (
<StyledRevisionMenu
document={document}
@@ -58,10 +56,9 @@ const StyledRevisionMenu = styled(RevisionMenu)`
const StyledNavLink = styled(NavLink)`
color: ${props => props.theme.text};
display: block;
padding: 16px;
padding: 8px 16px;
font-size: 15px;
position: relative;
height: 100px;
`;
const Author = styled(Flex)`