Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go-tui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ else
$(error Unsupported platform: $(PLATFORM))
endif

DITTO_SDK_URL = "https://software.ditto.live/go/Ditto/$(DITTO_SDK_VERSION)/libs/libdittoffi-$(DITTO_PLATFORM).tar.gz"
DITTO_SDK_URL = "https://software.ditto.live/go/Ditto/$(DITTO_SDK_VERSION)/dist/libdittoffi-$(DITTO_PLATFORM).tar.gz"

# Build the application
.PHONY: build
Expand Down
32 changes: 11 additions & 21 deletions go-tui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (a *App) handleNormalMode(e ui.Event) {
}
a.render()

case "<Enter>", " ":
case "<Enter>", "<Space>":
if task, ok := a.getSelectedTask(); ok {
go a.toggleTask(task.ID, !task.Done)
}
Expand Down Expand Up @@ -436,7 +436,7 @@ func (a *App) createTask(title string) {

result, err := a.ditto.Store().Execute(
"INSERT INTO tasks VALUES (:task)",
map[string]interface{}{"task": task},
ditto.QueryArguments{"task": task},
)
if err != nil {
a.setError(err.Error())
Expand All @@ -448,7 +448,7 @@ func (a *App) createTask(title string) {
func (a *App) updateTask(id, title string) {
result, err := a.ditto.Store().Execute(
"UPDATE tasks SET title = :title WHERE _id = :id",
map[string]interface{}{
ditto.QueryArguments{
"title": title,
"id": id,
},
Expand All @@ -463,7 +463,7 @@ func (a *App) updateTask(id, title string) {
func (a *App) toggleTask(id string, done bool) {
result, err := a.ditto.Store().Execute(
"UPDATE tasks SET done = :done WHERE _id = :id",
map[string]interface{}{
ditto.QueryArguments{
"done": done,
"id": id,
},
Expand All @@ -478,7 +478,7 @@ func (a *App) toggleTask(id string, done bool) {
func (a *App) deleteTask(id string) {
result, err := a.ditto.Store().Execute(
"UPDATE tasks SET deleted = true WHERE _id = :id",
map[string]interface{}{"id": id},
ditto.QueryArguments{"id": id},
)
if err != nil {
a.setError(err.Error())
Expand Down Expand Up @@ -514,23 +514,13 @@ func parseTasks(result *ditto.QueryResult) []Task {
return []Task{}
}

// Don't pre-allocate when we're filtering
var tasks []Task
items := result.Items()
for _, queryItem := range items {
// Get the value as a map
item := queryItem.Value()

// Parse the task from the document
task := Task{
ID: getStringValue(item, "_id"),
Title: getStringValue(item, "title"),
Done: getBoolValue(item, "done"),
Deleted: getBoolValue(item, "deleted"),
}
if !task.Deleted {
tasks = append(tasks, task)
tasks := make([]Task, 0, result.ItemCount())
for _, queryItem := range result.Items() {
var task Task
if err := queryItem.UnmarshalTo(&task); err != nil {
panic(err)
}
tasks = append(tasks, task)
}
return tasks
}
Expand Down
Loading