Skip to content

Commit 0b1f43b

Browse files
committed
fix move todoist
1 parent 8986298 commit 0b1f43b

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

core/Objects/Item.vala

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,7 @@ public class Objects.Item : Objects.BaseObject {
15231523
_move (project.id, _section_id);
15241524
} else if (project.source_type == SourceType.TODOIST) {
15251525
loading = true;
1526+
sensitive = false;
15261527

15271528
string move_id = project.id;
15281529
string move_type = "project_id";
@@ -1543,7 +1544,8 @@ public class Objects.Item : Objects.BaseObject {
15431544
});
15441545
} else if (project.source_type == SourceType.CALDAV) {
15451546
loading = true;
1546-
1547+
sensitive = false;
1548+
15471549
move_caldav_recursive.begin (project, _section_id);
15481550
}
15491551
}
@@ -1762,4 +1764,29 @@ public class Objects.Item : Objects.BaseObject {
17621764

17631765
return response;
17641766
}
1767+
1768+
public void to_string () {
1769+
print ("_________________________________\n");
1770+
print ("ID: %s\n", id);
1771+
print ("Content: %s\n", content);
1772+
print ("Description: %s\n", description);
1773+
print ("Project ID: %s\n", project_id);
1774+
print ("Section ID: %s\n", section_id);
1775+
print ("Parent ID: %s\n", parent_id);
1776+
print ("Priority: %d (%s)\n", priority, priority_text);
1777+
print ("Checked: %s\n", checked ? "true" : "false");
1778+
print ("Pinned: %s\n", pinned ? "true" : "false");
1779+
print ("Has Due: %s\n", has_due ? "true" : "false");
1780+
if (has_due) {
1781+
print ("Due Date: %s\n", due.date);
1782+
}
1783+
print ("Child Order: %d\n", child_order);
1784+
print ("Added At: %s\n", added_at);
1785+
print ("Completed At: %s\n", completed_at);
1786+
print ("Labels: %d\n", labels.size);
1787+
foreach (var label in labels) {
1788+
print (" - %s\n", label.name);
1789+
}
1790+
print ("---------------------------------\n");
1791+
}
17651792
}

core/Utils/Util.vala

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ We hope you’ll enjoy using Planify!""");
809809
return generator.to_data (null);
810810
}
811811

812-
public async void move_backend_type_item (Objects.Item item, Objects.Project target_project, string parent_id = "") {
812+
public async void move_backend_type_item (Objects.Item item, Objects.Project target_project, string parent_id = "", bool notify = true) {
813813
var new_item = item.duplicate ();
814814
new_item.project_id = target_project.id;
815815
new_item.parent_id = parent_id;
@@ -819,14 +819,14 @@ We hope you’ll enjoy using Planify!""");
819819

820820
if (target_project.source_type == SourceType.LOCAL) {
821821
new_item.id = Util.get_default ().generate_id (new_item);
822-
yield add_final_duplicate_item (new_item, item);
822+
yield add_final_duplicate_item (new_item, item, notify);
823823
} else if (target_project.source_type == SourceType.TODOIST) {
824824
HttpResponse response = yield Services.Todoist.get_default ().add (new_item);
825825
item.loading = false;
826826

827827
if (response.status) {
828828
new_item.id = response.data;
829-
yield add_final_duplicate_item (new_item, item);
829+
yield add_final_duplicate_item (new_item, item, notify);
830830
}
831831
} else if (target_project.source_type == SourceType.CALDAV) {
832832
new_item.id = Util.get_default ().generate_id (new_item);
@@ -836,13 +836,17 @@ We hope you’ll enjoy using Planify!""");
836836
item.loading = false;
837837

838838
if (response.status) {
839-
yield add_final_duplicate_item (new_item, item);
839+
yield add_final_duplicate_item (new_item, item, notify);
840840
}
841841
}
842842
}
843843

844-
public async void add_final_duplicate_item (Objects.Item new_item, Objects.Item item) {
845-
new_item.project.add_item_if_not_exists (new_item);
844+
public async void add_final_duplicate_item (Objects.Item new_item, Objects.Item item, bool notify = true) {
845+
if (new_item.has_parent) {
846+
new_item.parent.add_item_if_not_exists (new_item);
847+
} else {
848+
new_item.project.add_item_if_not_exists (new_item);
849+
}
846850

847851
foreach (Objects.Reminder reminder in item.reminders) {
848852
var _reminder = reminder.duplicate ();
@@ -859,12 +863,14 @@ We hope you’ll enjoy using Planify!""");
859863
}
860864

861865
foreach (Objects.Item subitem in item.items) {
862-
yield move_backend_type_item (subitem, new_item.project, new_item.id);
866+
yield move_backend_type_item (subitem, new_item.project, new_item.id, false);
863867
}
864868

865-
Services.EventBus.get_default ().send_toast (
866-
create_toast (_("Task moved to %s".printf (new_item.project.name)))
867-
);
869+
if (notify) {
870+
Services.EventBus.get_default ().send_toast (
871+
create_toast (_("Task moved to %s".printf (new_item.project.name)))
872+
);
873+
}
868874

869875
item.delete_item ();
870876
}

0 commit comments

Comments
 (0)