mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Debounce deletion of un-referenced attachments --> don't fixes but mitigates the problems of #3103
This commit is contained in:
@@ -53,6 +53,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.focusHandler = () => {
|
this.focusHandler = () => {
|
||||||
ipcRenderer.send('editor:focused', true)
|
ipcRenderer.send('editor:focused', true)
|
||||||
}
|
}
|
||||||
|
const debouncedDeletionOfAttachments = _.debounce(attachmentManagement.deleteAttachmentsNotPresentInNote, 30000)
|
||||||
this.blurHandler = (editor, e) => {
|
this.blurHandler = (editor, e) => {
|
||||||
ipcRenderer.send('editor:focused', false)
|
ipcRenderer.send('editor:focused', false)
|
||||||
if (e == null) return null
|
if (e == null) return null
|
||||||
@@ -64,16 +65,11 @@ export default class CodeEditor extends React.Component {
|
|||||||
el = el.parentNode
|
el = el.parentNode
|
||||||
}
|
}
|
||||||
this.props.onBlur != null && this.props.onBlur(e)
|
this.props.onBlur != null && this.props.onBlur(e)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
storageKey,
|
storageKey,
|
||||||
noteKey
|
noteKey
|
||||||
} = this.props
|
} = this.props
|
||||||
attachmentManagement.deleteAttachmentsNotPresentInNote(
|
debouncedDeletionOfAttachments(this.editor.getValue(), storageKey, noteKey)
|
||||||
this.editor.getValue(),
|
|
||||||
storageKey,
|
|
||||||
noteKey
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.pasteHandler = (editor, e) => {
|
this.pasteHandler = (editor, e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|||||||
@@ -584,6 +584,7 @@ function deleteAttachmentFolder (storageKey, noteKey) {
|
|||||||
* @param noteKey NoteKey of the current note. Is used to determine the belonging attachment folder.
|
* @param noteKey NoteKey of the current note. Is used to determine the belonging attachment folder.
|
||||||
*/
|
*/
|
||||||
function deleteAttachmentsNotPresentInNote (markdownContent, storageKey, noteKey) {
|
function deleteAttachmentsNotPresentInNote (markdownContent, storageKey, noteKey) {
|
||||||
|
console.log('deleteAtt')
|
||||||
if (storageKey == null || noteKey == null || markdownContent == null) {
|
if (storageKey == null || noteKey == null || markdownContent == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -617,8 +618,6 @@ function deleteAttachmentsNotPresentInNote (markdownContent, storageKey, noteKey
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
console.info('Attachment folder ("' + attachmentFolder + '") did not exist..')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user