Skip to content

Commit

Permalink
Clean up disable restore note button when is newset revision (#2248)
Browse files Browse the repository at this point in the history
The disable on the restore note button when you are currently on the most recent revision is CSS and was not actually disabling the functionality. Additionally, the logic failed when you first opened the revisions panel. This gets everything into tip top.
  • Loading branch information
belcherj authored Jul 28, 2020
1 parent 1989e63 commit f70fd7a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/revision-selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class RevisionSelector extends Component<Props> {

onAcceptRevision = () => {
const { noteId, openedRevision, restoreRevision } = this.props;

restoreRevision(noteId, openedRevision);
};

Expand Down Expand Up @@ -66,7 +65,9 @@ export class RevisionSelector extends Component<Props> {
revisions && openedRevision
? [...revisions.keys()].indexOf(openedRevision)
: -1;
const isNewest = openedRevision && selectedIndex === revisions?.size - 1;
const isNewest =
!openedRevision ||
(openedRevision && selectedIndex === revisions?.size - 1);

const revisionDate = format(
(openedRevision
Expand All @@ -75,10 +76,6 @@ export class RevisionSelector extends Component<Props> {
'MMM d, yyyy h:mm a'
);

const revisionButtonStyle: CSSProperties = isNewest
? { opacity: '0.5', pointerEvents: 'none' }
: {};

const mainClasses = classNames('revision-selector', {
'is-visible': isViewingRevisions,
});
Expand All @@ -105,7 +102,7 @@ export class RevisionSelector extends Component<Props> {
Cancel
</button>
<button
style={revisionButtonStyle}
disabled={isNewest}
className="button button-primary button-compact"
onClick={this.onAcceptRevision}
>
Expand Down

0 comments on commit f70fd7a

Please sign in to comment.