1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

refactor: Improve sendWakatimeHeartBeat.

This commit is contained in:
Luis Reinoso
2020-05-23 12:21:43 -05:00
parent 6fe6794796
commit 1aaba74e24
2 changed files with 22 additions and 38 deletions

View File

@@ -120,14 +120,11 @@ export default class CodeEditor extends React.Component {
const { storageKey, noteKey } = this.props
const storage = findStorage(storageKey)
if (storage)
sendWakatimeHeartBeat(
storage.path,
noteKey,
storage.name,
false,
false,
true
)
sendWakatimeHeartBeat(storage.path, noteKey, storage.name, {
isWrite: false,
hasFileChanges: false,
isFileChange: true
})
}
handleSearch(msg) {
@@ -813,25 +810,17 @@ export default class CodeEditor extends React.Component {
const storage = findStorage(storageKey)
if (this.props.onChange) {
this.props.onChange(editor)
if (storage)
sendWakatimeHeartBeat(
storage.path,
noteKey,
storage.name,
true,
true,
false
)
} else {
if (storage)
sendWakatimeHeartBeat(
storage.path,
noteKey,
storage.name,
false,
false,
false
)
}
const isWrite = !!this.props.onChange
const hasFileChanges = isWrite
if (storage) {
sendWakatimeHeartBeat(storage.path, noteKey, storage.name, {
isWrite,
hasFileChanges,
isFileChange: false
})
}
}
@@ -965,14 +954,11 @@ export default class CodeEditor extends React.Component {
const { storageKey, noteKey } = this.props
const storage = findStorage(storageKey)
if (storage)
sendWakatimeHeartBeat(
storage.path,
noteKey,
storage.name,
false,
false,
true
)
sendWakatimeHeartBeat(storage.path, noteKey, storage.name, {
isWrite: false,
hasFileChanges: false,
isFileChange: true
})
}
setValue(value) {

View File

@@ -7,9 +7,7 @@ function sendWakatimeHeartBeat(
storagePath,
noteKey,
storageName,
isWrite,
hasFileChanges,
isFileChange
{ isWrite, hasFileChanges, isFileChange }
) {
if (
config.get().wakatime.isActive &&