Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up disable restore note button when is newset revision #2248

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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