From 87c565a63fa2c193d40178012b160bdb60291c53 Mon Sep 17 00:00:00 2001 From: Alain Date: Mon, 4 Mar 2024 17:37:18 -0500 Subject: [PATCH] fix #1176 --- core/Objects/Item.vala | 10 +++++----- core/Services/CalDAV.vala | 3 +-- core/Services/Todoist.vala | 5 ++++- src/Layouts/ProjectRow.vala | 1 - 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/Objects/Item.vala b/core/Objects/Item.vala index 1f1331dd0..71394ebe6 100644 --- a/core/Objects/Item.vala +++ b/core/Objects/Item.vala @@ -1383,7 +1383,7 @@ public class Objects.Item : Objects.BaseObject { } } - public void move (Objects.Project project, string section_id) { + public void move (Objects.Project project, string _section_id) { show_item = false; if (project.backend_type == BackendType.LOCAL) { @@ -1391,11 +1391,11 @@ public class Objects.Item : Objects.BaseObject { } else if (project.backend_type == BackendType.TODOIST) { loading = true; - string move_id = project_id; + string move_id = project.id; string move_type = "project_id"; - if (section_id != "") { + if (_section_id != "") { move_type = "section_id"; - move_id = section_id; + move_id = _section_id; } Services.Todoist.get_default ().move_item.begin (this, move_type, move_id, (obj, res) => { @@ -1411,7 +1411,7 @@ public class Objects.Item : Objects.BaseObject { } else if (project.backend_type == BackendType.CALDAV) { loading = true; - Services.CalDAV.get_default ().move_task.begin (this, project_id, (obj, res) => { + Services.CalDAV.get_default ().move_task.begin (this, project.id, (obj, res) => { var response = Services.CalDAV.get_default ().move_task.end (res); loading = false; diff --git a/core/Services/CalDAV.vala b/core/Services/CalDAV.vala index d16ca19fc..9474c1c15 100644 --- a/core/Services/CalDAV.vala +++ b/core/Services/CalDAV.vala @@ -929,7 +929,6 @@ public class Services.CalDAV : GLib.Object { public async HttpResponse move_task (Objects.Item item, string project_id) { var server_url = Services.Settings.get_default ().settings.get_string ("caldav-server-url"); var username = Services.Settings.get_default ().settings.get_string ("caldav-username"); - var url = "%s/remote.php/dav/calendars/%s/%s/%s".printf (server_url, username, item.project.id, item.ics); var destination = "/remote.php/dav/calendars/%s/%s/%s".printf (username, project_id, item.ics); @@ -943,7 +942,7 @@ public class Services.CalDAV : GLib.Object { try { yield session.send_and_read_async (message, GLib.Priority.HIGH, null); - if (message.status_code == 201) { + if (message.status_code == 201 || message.status_code == 204) { response.status = true; } } catch (Error e) { diff --git a/core/Services/Todoist.vala b/core/Services/Todoist.vala index a71ec4084..5a1a8d0c5 100644 --- a/core/Services/Todoist.vala +++ b/core/Services/Todoist.vala @@ -56,7 +56,8 @@ public class Services.Todoist : GLib.Object { var network_monitor = GLib.NetworkMonitor.get_default (); network_monitor.network_changed.connect (() => { - if (GLib.NetworkMonitor.get_default ().network_available && is_logged_in () && + if (GLib.NetworkMonitor.get_default ().network_available && + is_logged_in () && Services.Settings.get_default ().settings.get_boolean ("todoist-sync-server")) { sync_async (); } @@ -1211,6 +1212,7 @@ public class Services.Todoist : GLib.Object { public async HttpResponse move_item (Objects.Item item, string type, string id) { string uuid = Util.get_default ().generate_string (); string json = item.get_move_item (uuid, type, id); + print ("%s\n".printf (json)); var message = new Soup.Message ("POST", TODOIST_SYNC_URL); message.request_headers.append ( @@ -1223,6 +1225,7 @@ public class Services.Todoist : GLib.Object { try { GLib.Bytes stream = yield session.send_and_read_async (message, GLib.Priority.HIGH, null); + print ("%s\n".printf ((string) stream.get_data ())); parser.load_from_data ((string) stream.get_data ()); print_root (parser.get_root ()); diff --git a/src/Layouts/ProjectRow.vala b/src/Layouts/ProjectRow.vala index 5fa03e778..a66a573e2 100644 --- a/src/Layouts/ProjectRow.vala +++ b/src/Layouts/ProjectRow.vala @@ -339,7 +339,6 @@ public class Layouts.ProjectRow : Gtk.ListBoxRow { drop_magic_button_target.drop.connect ((value, x, y) => { var dialog = new Dialogs.Project.new (project.backend_type, false, project.id); dialog.show (); - return true; });