summaryrefslogtreecommitdiff
path: root/todo-widget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2020-12-05 20:57:04 -0500
committerstreetturtle <streetturtle@gmail.com>2020-12-05 20:57:04 -0500
commita0cd854a4d36167456bb28d255bf96a32321bf2a (patch)
treeb42aa4e39d0b46144ed64d1d4f20e90c28465d3d /todo-widget
parentd9eb3885eea90e06b79ff8fc4b2d1c1b8f5e4cfd (diff)
fix more warnings
Diffstat (limited to 'todo-widget')
-rw-r--r--todo-widget/todo.lua18
1 files changed, 8 insertions, 10 deletions
diff --git a/todo-widget/todo.lua b/todo-widget/todo.lua
index 14e3dc2..74b3d1b 100644
--- a/todo-widget/todo.lua
+++ b/todo-widget/todo.lua
@@ -23,7 +23,7 @@ local GET_TODO_ITEMS = 'bash -c "cat ' .. STORAGE .. '"'
local rows = { layout = wibox.layout.fixed.vertical }
local todo_widget = {}
-
+local update_widget
todo_widget.widget = wibox.widget {
{
{
@@ -115,7 +115,7 @@ add_button:connect_signal("button::press", function()
local res = json.decode(stdout)
table.insert(res.todo_items, {todo_item = input_text, status = false})
spawn.easy_async_with_shell("echo '" .. json.encode(res) .. "' > " .. STORAGE, function()
- spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end)
+ spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end)
end)
end)
end
@@ -202,7 +202,7 @@ local function worker(user_args)
trash_button:connect_signal("button::press", function()
table.remove(result.todo_items, i)
spawn.easy_async_with_shell("printf '" .. json.encode(result) .. "' > " .. STORAGE, function ()
- spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end)
+ spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end)
end)
end)
@@ -218,7 +218,7 @@ local function worker(user_args)
result.todo_items[i] = result.todo_items[i-1]
result.todo_items[i-1] = temp
spawn.easy_async_with_shell("printf '" .. json.encode(result) .. "' > " .. STORAGE, function ()
- spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end)
+ spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end)
end)
end)
@@ -233,7 +233,7 @@ local function worker(user_args)
result.todo_items[i] = result.todo_items[i+1]
result.todo_items[i+1] = temp
spawn.easy_async_with_shell("printf '" .. json.encode(result) .. "' > " .. STORAGE, function ()
- spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end)
+ spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end)
end)
end)
@@ -242,13 +242,11 @@ local function worker(user_args)
layout = wibox.layout.fixed.vertical
}
- if 1 == #result.todo_items then
- -- one item, no need in arrows
- elseif i == 1 then
+ if i == 1 and #result.todo_items > 1 then
table.insert(move_buttons, move_down)
- elseif i == #result.todo_items then
+ elseif i == #result.todo_items and #result.todo_items > 1 then
table.insert(move_buttons, move_up)
- else
+ elseif #result.todo_items > 1 then
table.insert(move_buttons, move_up)
table.insert(move_buttons, move_down)
end