mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge pull request #588 from Seanstoppable/fixscrollableandtodoist
Fix delete/close of todoist
This commit is contained in:
commit
46a4c82e1a
@ -104,25 +104,26 @@ func (widget *Widget) Unselect() {
|
||||
// Close closes the currently-selected task in the currently-selected project
|
||||
func (w *Widget) Close() {
|
||||
w.CurrentProject().closeSelectedTask()
|
||||
w.SetItemCount(len(w.CurrentProject().tasks))
|
||||
|
||||
if w.CurrentProject().isLast() {
|
||||
w.Prev()
|
||||
return
|
||||
}
|
||||
|
||||
w.Next()
|
||||
w.CurrentProject().index = w.Selected
|
||||
w.RenderFunction()
|
||||
}
|
||||
|
||||
// Delete deletes the currently-selected task in the currently-selected project
|
||||
func (w *Widget) Delete() {
|
||||
w.CurrentProject().deleteSelectedTask()
|
||||
w.SetItemCount(len(w.CurrentProject().tasks))
|
||||
|
||||
if w.CurrentProject().isLast() {
|
||||
w.Prev()
|
||||
return
|
||||
}
|
||||
|
||||
w.Next()
|
||||
w.CurrentProject().index = w.Selected
|
||||
w.RenderFunction()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -35,6 +35,9 @@ func (widget *ScrollableWidget) SetRenderFunction(displayFunc func()) {
|
||||
|
||||
func (widget *ScrollableWidget) SetItemCount(items int) {
|
||||
widget.maxItems = items
|
||||
if items == 0 {
|
||||
widget.Selected = -1
|
||||
}
|
||||
}
|
||||
|
||||
func (widget *ScrollableWidget) GetSelected() int {
|
||||
@ -54,6 +57,9 @@ func (widget *ScrollableWidget) Next() {
|
||||
if widget.Selected >= widget.maxItems {
|
||||
widget.Selected = 0
|
||||
}
|
||||
if widget.maxItems == 0 {
|
||||
widget.Selected = -1
|
||||
}
|
||||
widget.RenderFunction()
|
||||
}
|
||||
|
||||
@ -62,6 +68,9 @@ func (widget *ScrollableWidget) Prev() {
|
||||
if widget.Selected < 0 {
|
||||
widget.Selected = widget.maxItems - 1
|
||||
}
|
||||
if widget.maxItems == 0 {
|
||||
widget.Selected = -1
|
||||
}
|
||||
widget.RenderFunction()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user