Skip to content

Commit

Permalink
Discard all note changes in read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jun 12, 2020
1 parent 499ce25 commit c660e74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/components/item/view.js
Expand Up @@ -139,19 +139,17 @@ class ItemView extends React.PureComponent {
}, NOTE.AUTOSAVE_DELAY)

handleNoteChange = (note, changed, isBlank) => {
if (!this.props.isReadOnly) {
if (note.id != null) {
note.modified = new Date()
if (isBlank) this.handleNoteSave.cancel()
else this.handleNoteSave(note, { changed })
if (note.id != null) {
note.modified = new Date()
if (isBlank) this.handleNoteSave.cancel()
else this.handleNoteSave(note, { changed })

} else {
if (note.created == null && !isBlank) {
note.created = Date.now()
note.photo = this.props.photo.id
note.selection = this.props.activeSelection
this.props.onNoteCreate(note)
}
} else {
if (note.created == null && !isBlank) {
note.created = Date.now()
note.photo = this.props.photo.id
note.selection = this.props.activeSelection
this.props.onNoteCreate(note)
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/components/note/pad.js
Expand Up @@ -25,6 +25,9 @@ class NotePad extends React.PureComponent {
}

handleChange = (state, hasDocChanged) => {
if (this.props.isDisabled || this.props.isReadOnly)
return

let note = { ...this.props.note, state }

if (hasDocChanged) {
Expand Down

0 comments on commit c660e74

Please sign in to comment.