Add niceties to time page

This commit is contained in:
Martin Pander
2026-02-02 12:44:12 +01:00
parent 9940316ace
commit 81b9d87935
6 changed files with 395 additions and 26 deletions

View File

@ -31,6 +31,7 @@ type TimeWarrior interface {
CancelTracking() error
DeleteInterval(id int) error
FillInterval(id int) error
JoinInterval(id int) error
ModifyInterval(interval *Interval, adjust bool) error
GetSummary(filter ...string) string
GetActive() *Interval
@ -232,6 +233,21 @@ func (ts *TimeSquire) FillInterval(id int) error {
return nil
}
func (ts *TimeSquire) JoinInterval(id int) error {
ts.mutex.Lock()
defer ts.mutex.Unlock()
// Join the current interval with the previous one
// The previous interval has id+1 (since intervals are ordered newest first)
cmd := exec.Command(twBinary, append(ts.defaultArgs, []string{"join", fmt.Sprintf("@%d", id+1), fmt.Sprintf("@%d", id)}...)...)
if err := cmd.Run(); err != nil {
slog.Error("Failed joining interval:", err)
return err
}
return nil
}
func (ts *TimeSquire) ModifyInterval(interval *Interval, adjust bool) error {
ts.mutex.Lock()
defer ts.mutex.Unlock()