Skip to content

Commit

Permalink
fix #1171
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Mar 4, 2024
1 parent 87c565a commit f6f2b10
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 140 deletions.
2 changes: 0 additions & 2 deletions core/Services/Todoist.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,6 @@ 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 (
Expand All @@ -1225,7 +1224,6 @@ 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 ());
Expand Down
9 changes: 9 additions & 0 deletions data/io.github.alainm23.planify.appdata.xml.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
<url type="donation">https://www.patreon.com/alainm23</url>
<launchable type="desktop-id">@[email protected]</launchable>
<releases>
<release version="4.5.2" date="2024-03-04">
<description translatable="no">
<ul>
<li>Fixed bug that improves CalDAV sync.</li>
<li>Fixed bug when moving tasks.</li>
</ul>
</description>
</release>

<release version="4.5.1" date="2024-03-01">
<description translatable="no">
<ul>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'io.github.alainm23.planify',
'vala', 'c',
version: '4.5.1'
version: '4.5.2'
)

gnome = import('gnome')
Expand Down
17 changes: 13 additions & 4 deletions src/Layouts/ItemRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class Layouts.ItemRow : Layouts.ItemBase {
content_label.remove_css_class ("dim-label");
}

disable_drag_and_drop ();
_disable_drag_and_drop ();
} else {
itemrow_box.remove_css_class ("card-selected");
itemrow_box.remove_css_class ("card");
Expand All @@ -124,7 +124,10 @@ public class Layouts.ItemRow : Layouts.ItemBase {
labels_summary.check_revealer ();

update_request ();
build_drag_and_drop ();

if (drag_enabled) {
build_drag_and_drop ();
}
}
}
get {
Expand Down Expand Up @@ -176,6 +179,7 @@ public class Layouts.ItemRow : Layouts.ItemBase {
public uint destroy_timeout { get; set; default = 0; }
public uint complete_timeout { get; set; default = 0; }
public bool on_drag = false;
public bool drag_enabled { get; set; default = true; }

public signal void item_added ();
public signal void widget_destroyed ();
Expand Down Expand Up @@ -1306,7 +1310,7 @@ public class Layouts.ItemRow : Layouts.ItemBase {
item.move (project, section_id);
}
}
private void build_drag_and_drop () {
public void build_drag_and_drop () {
// Drop Motion
build_drop_motion ();

Expand Down Expand Up @@ -1543,7 +1547,12 @@ public class Layouts.ItemRow : Layouts.ItemBase {
})] = drop_order_target;
}

private void disable_drag_and_drop () {
public void disable_drag_and_drop () {
drag_enabled = false;
_disable_drag_and_drop ();
}

private void _disable_drag_and_drop () {
remove_controller (drop_motion_ctrl);
itemrow_box.remove_controller (drag_source);
itemrow_box.remove_controller (drop_target);
Expand Down
49 changes: 25 additions & 24 deletions src/Views/Filter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public class Views.Filter : Adw.Bin {
Services.EventBus.get_default ().checked_toggled.connect (valid_checked_item);

Services.EventBus.get_default ().item_moved.connect ((item) => {
if (items.has_key (item.id_string)) {
items[item.id_string].update_request ();
if (items.has_key (item.id)) {
items[item.id].update_request ();
}
});

Expand Down Expand Up @@ -190,21 +190,22 @@ public class Views.Filter : Adw.Bin {
}

private void add_item (Objects.Item item) {
items [item.id_string] = new Layouts.ItemRow (item) {
items [item.id] = new Layouts.ItemRow (item) {
show_project_label = true
};
listbox.append (items [item.id_string]);
items [item.id].disable_drag_and_drop ();
listbox.append (items [item.id]);
}

private void valid_add_item (Objects.Item item, bool insert = true) {
if (filter is Objects.Priority) {
Objects.Priority priority = ((Objects.Priority) filter);

if (!items.has_key (item.id_string) && item.priority == priority.priority && insert) {
if (!items.has_key (item.id) && item.priority == priority.priority && insert) {
add_item (item);
}
} else if (filter is Objects.Completed) {
if (!items.has_key (item.id_string) && item.checked && insert) {
if (!items.has_key (item.id) && item.checked && insert) {
add_item (item);
}
}
Expand All @@ -213,9 +214,9 @@ public class Views.Filter : Adw.Bin {
}

private void valid_delete_item (Objects.Item item) {
if (items.has_key (item.id_string)) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id)) {
items[item.id].hide_destroy ();
items.unset (item.id);
}

validate_placeholder ();
Expand All @@ -225,21 +226,21 @@ public class Views.Filter : Adw.Bin {
if (filter is Objects.Priority) {
Objects.Priority priority = ((Objects.Priority) filter);

if (items.has_key (item.id_string) && item.priority != priority.priority) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id) && item.priority != priority.priority) {
items[item.id].hide_destroy ();
items.unset (item.id);
}

if (items.has_key (item.id_string) && !item.checked) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id) && !item.checked) {
items[item.id].hide_destroy ();
items.unset (item.id);
}

valid_add_item (item);
} else if (filter is Objects.Completed) {
if (items.has_key (item.id_string) && item.checked) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id) && item.checked) {
items[item.id].hide_destroy ();
items.unset (item.id);
}

valid_add_item (item);
Expand All @@ -251,9 +252,9 @@ public class Views.Filter : Adw.Bin {
private void valid_checked_item (Objects.Item item, bool old_checked) {
if (filter is Objects.Priority) {
if (!old_checked) {
if (items.has_key (item.id_string) && item.completed) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id) && item.completed) {
items[item.id].hide_destroy ();
items.unset (item.id);
}
} else {
valid_update_item (item);
Expand All @@ -262,9 +263,9 @@ public class Views.Filter : Adw.Bin {
if (!old_checked) {
valid_update_item (item);
} else {
if (items.has_key (item.id_string) && !item.completed) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id) && !item.completed) {
items[item.id].hide_destroy ();
items.unset (item.id);
}
}
}
Expand Down
19 changes: 10 additions & 9 deletions src/Views/Label/Label.vala
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class Views.Label : Adw.Bin {
}

private void valid_add_item (Objects.Item item, bool insert = true) {
// if (!items.has_key (item.id_string) && item.labels.has_key (label.id_string)
// if (!items.has_key (item.id) && item.labels.has_key (label.id)
// && insert) {
// add_item (item);
// }
Expand All @@ -147,18 +147,18 @@ public class Views.Label : Adw.Bin {
}

private void valid_delete_item (Objects.Item item) {
// if (items.has_key (item.id_string)) {
// items[item.id_string].hide_destroy ();
// items.unset (item.id_string);
// if (items.has_key (item.id)) {
// items[item.id].hide_destroy ();
// items.unset (item.id);
// }

// validate_placeholder ();
}

private void valid_update_item (Objects.Item item) {
// if (items.has_key (item.id_string) && !item.labels.has_key (label.id_string)) {
// items[item.id_string].hide_destroy ();
// items.unset (item.id_string);
// if (items.has_key (item.id) && !item.labels.has_key (label.id)) {
// items[item.id].hide_destroy ();
// items.unset (item.id);
// }

// valid_add_item (item);
Expand All @@ -179,10 +179,11 @@ public class Views.Label : Adw.Bin {
}

private void add_item (Objects.Item item) {
items [item.id_string] = new Layouts.ItemRow (item) {
items [item.id] = new Layouts.ItemRow (item) {
show_project_label = true
};
listbox.append (items [item.id_string]);
items [item.id].disable_drag_and_drop ();
listbox.append (items [item.id]);
}

public void update_request () {
Expand Down
4 changes: 2 additions & 2 deletions src/Views/Label/Labels.vala
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ public class Views.Labels : Adw.Bin {
});

labels_local_header.row_activated.connect ((row) => {
Services.EventBus.get_default ().pane_selected (PaneType.LABEL, ((Layouts.LabelRow) row).label.id_string);
Services.EventBus.get_default ().pane_selected (PaneType.LABEL, ((Layouts.LabelRow) row).label.id);
});

labels_todoist_header.row_activated.connect ((row) => {
Services.EventBus.get_default ().pane_selected (PaneType.LABEL, ((Layouts.LabelRow) row).label.id_string);
Services.EventBus.get_default ().pane_selected (PaneType.LABEL, ((Layouts.LabelRow) row).label.id);
});

Services.Database.get_default ().label_added.connect ((label) => {
Expand Down
23 changes: 12 additions & 11 deletions src/Views/Pinboard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public class Views.Pinboard : Adw.Bin {
Services.Database.get_default ().item_updated.connect (valid_update_item);

Services.EventBus.get_default ().item_moved.connect ((item) => {
if (items.has_key (item.id_string)) {
items[item.id_string].update_request ();
if (items.has_key (item.id)) {
items[item.id].update_request ();
}
});

Expand All @@ -144,26 +144,26 @@ public class Views.Pinboard : Adw.Bin {
}

private void valid_add_item (Objects.Item item, bool insert = true) {
if (!items.has_key (item.id_string) && item.pinned && !item.checked) {
if (!items.has_key (item.id) && item.pinned && !item.checked) {
add_item (item);
}

validate_placeholder ();
}

private void valid_delete_item (Objects.Item item) {
if (items.has_key (item.id_string)) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id)) {
items[item.id].hide_destroy ();
items.unset (item.id);
}

validate_placeholder ();
}

private void valid_update_item (Objects.Item item) {
if (items.has_key (item.id_string) && (!item.pinned || item.checked)) {
items[item.id_string].hide_destroy ();
items.unset (item.id_string);
if (items.has_key (item.id) && (!item.pinned || item.checked)) {
items[item.id].hide_destroy ();
items.unset (item.id);
}

valid_add_item (item);
Expand All @@ -176,9 +176,10 @@ public class Views.Pinboard : Adw.Bin {
}

private void add_item (Objects.Item item) {
items [item.id_string] = new Layouts.ItemRow (item) {
items [item.id] = new Layouts.ItemRow (item) {
show_project_label = true
};
listbox.append (items [item.id_string]);
items [item.id].disable_drag_and_drop ();
listbox.append (items [item.id]);
}
}
Loading

0 comments on commit f6f2b10

Please sign in to comment.