Skip to content

Commit

Permalink
Debounce deletion of un-referenced attachments --> don't fixes but mi…
Browse files Browse the repository at this point in the history
…tigates the problems of #3103
  • Loading branch information
ehhc authored and Rokt33r committed Jul 10, 2019
1 parent d37210a commit 55a7ee1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 2 additions & 6 deletions browser/components/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class CodeEditor extends React.Component {
this.focusHandler = () => {
ipcRenderer.send('editor:focused', true)
}
const debouncedDeletionOfAttachments = _.debounce(attachmentManagement.deleteAttachmentsNotPresentInNote, 30000)
this.blurHandler = (editor, e) => {
ipcRenderer.send('editor:focused', false)
if (e == null) return null
Expand All @@ -64,16 +65,11 @@ export default class CodeEditor extends React.Component {
el = el.parentNode
}
this.props.onBlur != null && this.props.onBlur(e)

const {
storageKey,
noteKey
} = this.props
attachmentManagement.deleteAttachmentsNotPresentInNote(
this.editor.getValue(),
storageKey,
noteKey
)
debouncedDeletionOfAttachments(this.editor.getValue(), storageKey, noteKey)
}
this.pasteHandler = (editor, e) => {
e.preventDefault()
Expand Down
3 changes: 1 addition & 2 deletions browser/main/lib/dataApi/attachmentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ function deleteAttachmentFolder (storageKey, noteKey) {
* @param noteKey NoteKey of the current note. Is used to determine the belonging attachment folder.
*/
function deleteAttachmentsNotPresentInNote (markdownContent, storageKey, noteKey) {
console.log('deleteAtt')
if (storageKey == null || noteKey == null || markdownContent == null) {
return
}
Expand Down Expand Up @@ -617,8 +618,6 @@ function deleteAttachmentsNotPresentInNote (markdownContent, storageKey, noteKey
}
})
})
} else {
console.info('Attachment folder ("' + attachmentFolder + '") did not exist..')
}
}

Expand Down

0 comments on commit 55a7ee1

Please sign in to comment.