Closed theotheo closed 6 months ago
Hi @theotheo
Thanks for this PR! and I like the idea of having different log files for different tasks, It makes sense for keeping track of things, but I'm a bit unsure about automatically using the file that's opened when we start the timer, I think it's easy to lose track or mix up where we started, I guess that's why you added a fallback to the daily note, it just seems not so intuitive for me. I'm open to merging this if we can add a explicit option for users to choose their fallback policy (None, File, Daily Note)
BTW, I've been considering implementing time stats into the log, so we could figure out which file gets the most attention during a session, and perhaps choose it as the file for logging, could that be an approach fits with your workflow?
Here's a snippet as a POC, let me know what you think.
const stat: Record<string, number> = {}
let currentFile: TFile | null | undefined =
this.app.workspace.getActiveViewOfType(MarkdownView)?.file
this.registerEvent(
this.app.workspace.on('active-leaf-change', () => {
const view =
this.app.workspace.getActiveViewOfType(MarkdownView)
if (view) {
let file = view.file
if (file?.extension == 'md') {
currentFile = file
} else {
currentFile = null
}
} else {
currentFile = null
}
}),
)
// update time
this.registerInterval(
window.setInterval(() => {
if (currentFile) {
let total = stat[currentFile.path]
stat[currentFile.path] = total ? total + 1 : 1
}
console.log(stat)
}, 1000),
)
see #11
Hello. Thank you for such a nice plugin! I would like to suggest a few additions.
My workflow involves logging into different files corresponding to different tasks. This way, I want to track how much time I've dedicated to specific tasks. Therefore, I added an option to log into the file that was active (open) when I started the timer. I updated the README accordingly.
However, there are a few questionable points:
TimerState
— it seems logical, but passing theTFile
tosaveLog
makes this function more tightly coupled. I don't like it, but I haven't come up with a better solution..md
-file. If not, I log it in Daily. This seems like a very specific solution. I understand if you don't like it.I would appreciate your feedback. I understand if this complication doesn't suit your taste. I have no problem using my fork of your excellent plugin!