Skip to content

Commit 55a7ee1

Browse files
ehhcRokt33r
authored andcommitted
Debounce deletion of un-referenced attachments --> don't fixes but mitigates the problems of #3103
1 parent d37210a commit 55a7ee1

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

browser/components/CodeEditor.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default class CodeEditor extends React.Component {
5353
this.focusHandler = () => {
5454
ipcRenderer.send('editor:focused', true)
5555
}
56+
const debouncedDeletionOfAttachments = _.debounce(attachmentManagement.deleteAttachmentsNotPresentInNote, 30000)
5657
this.blurHandler = (editor, e) => {
5758
ipcRenderer.send('editor:focused', false)
5859
if (e == null) return null
@@ -64,16 +65,11 @@ export default class CodeEditor extends React.Component {
6465
el = el.parentNode
6566
}
6667
this.props.onBlur != null && this.props.onBlur(e)
67-
6868
const {
6969
storageKey,
7070
noteKey
7171
} = this.props
72-
attachmentManagement.deleteAttachmentsNotPresentInNote(
73-
this.editor.getValue(),
74-
storageKey,
75-
noteKey
76-
)
72+
debouncedDeletionOfAttachments(this.editor.getValue(), storageKey, noteKey)
7773
}
7874
this.pasteHandler = (editor, e) => {
7975
e.preventDefault()

browser/main/lib/dataApi/attachmentManagement.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ function deleteAttachmentFolder (storageKey, noteKey) {
584584
* @param noteKey NoteKey of the current note. Is used to determine the belonging attachment folder.
585585
*/
586586
function deleteAttachmentsNotPresentInNote (markdownContent, storageKey, noteKey) {
587+
console.log('deleteAtt')
587588
if (storageKey == null || noteKey == null || markdownContent == null) {
588589
return
589590
}
@@ -617,8 +618,6 @@ function deleteAttachmentsNotPresentInNote (markdownContent, storageKey, noteKey
617618
}
618619
})
619620
})
620-
} else {
621-
console.info('Attachment folder ("' + attachmentFolder + '") did not exist..')
622621
}
623622
}
624623

0 commit comments

Comments
 (0)