Skip to content

Commit

Permalink
fix #1346
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Jun 21, 2024
1 parent ba71813 commit b6f51b4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
8 changes: 4 additions & 4 deletions core/Objects/Item.vala
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ public class Objects.Item : Objects.BaseObject {
});
}

public void update_async_timeout (string update_id = "", string key = "") {
public void update_async_timeout (string update_id = "") {
if (update_timeout_id != 0) {
Source.remove (update_timeout_id);
}
Expand All @@ -723,20 +723,20 @@ public class Objects.Item : Objects.BaseObject {
loading = true;

if (project.backend_type == BackendType.LOCAL) {
Services.Database.get_default ().update_item (this, update_id, key);
Services.Database.get_default ().update_item (this, update_id);
loading = false;
} else if (project.backend_type == BackendType.TODOIST) {
Services.Todoist.get_default ().update.begin (this, (obj, res) => {
Services.Todoist.get_default ().update.end (res);
Services.Database.get_default ().update_item (this, update_id, key);
Services.Database.get_default ().update_item (this, update_id);
loading = false;
});
} else if (project.backend_type == BackendType.CALDAV) {
Services.CalDAV.Core.get_default ().add_task.begin (this, true, (obj, res) => {
HttpResponse response = Services.CalDAV.Core.get_default ().add_task.end (res);

if (response.status) {
Services.Database.get_default ().update_item (this, update_id, key);
Services.Database.get_default ().update_item (this, update_id);
}

loading = false;
Expand Down
3 changes: 1 addition & 2 deletions core/Services/Database.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ public class Services.Database : GLib.Object {
stmt.reset ();
}

public void update_item (Objects.Item item, string update_id = "", string key = "") {
public void update_item (Objects.Item item, string update_id = "") {
item.updated_at = new GLib.DateTime.now_local ().to_string ();
Sqlite.Statement stmt;

Expand Down Expand Up @@ -1765,7 +1765,6 @@ public class Services.Database : GLib.Object {
if (stmt.step () == Sqlite.DONE) {
item.updated (update_id);
item_updated (item, update_id);
// add_item_event (Objects.ObjectEvent.for_update_item (item, key));
} else {
warning ("Error: %d: %s", db.errcode (), db.errmsg ());
}
Expand Down
4 changes: 1 addition & 3 deletions src/Layouts/ItemBoard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ public class Layouts.ItemBoard : Layouts.ItemBase {
child = repeat_box
};

due_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
margin_start = 6
};
due_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
due_box.append (due_label);
due_box.append (repeat_revealer);

Expand Down
24 changes: 19 additions & 5 deletions src/Layouts/ItemSidebarView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class Layouts.ItemSidebarView : Adw.Bin {

private Gee.HashMap<ulong, GLib.Object> signals_map = new Gee.HashMap<ulong, GLib.Object> ();
public string update_id { get; set; default = Util.get_default ().generate_id (); }

private ulong description_handler_change_id = 0;

public bool show_completed {
get {
if (Services.Settings.get_default ().settings.get_boolean ("always-show-completed-subtasks")) {
Expand Down Expand Up @@ -343,26 +344,39 @@ public class Layouts.ItemSidebarView : Adw.Bin {
signals_map[item.loading_change.connect (() => {
spinner_revealer.reveal_child = item.loading;
})] = item;

signals_map[current_buffer.changed.connect_after (() => {
update_content_description ();
})] = current_buffer;
}

public void disconnect_all () {
foreach (var entry in signals_map.entries) {
entry.value.disconnect (entry.key);
}

if (description_handler_change_id != 0) {
current_buffer.disconnect (description_handler_change_id);
description_handler_change_id = 0;
}

signals_map.clear ();
subitems.disconnect_all ();
attachments.disconnect_all ();
}

public void update_request () {
content_textview.buffer.text = item.content;

if (description_handler_change_id != 0) {
current_buffer.disconnect (description_handler_change_id);
description_handler_change_id = 0;
}

current_buffer.text = item.description;

if (description_handler_change_id == 0) {
description_handler_change_id = current_buffer.changed.connect (() => {
update_content_description ();
});
}

schedule_button.update_from_item (item);
priority_button.update_from_item (item);
status_button.update_from_item (item);
Expand Down
4 changes: 2 additions & 2 deletions src/Views/Project/List.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Authored by: Alain M. <[email protected]>
*/

public class Views.List : Gtk.Grid {
public class Views.List : Adw.Bin {
public Objects.Project project { get; construct; }

private Gtk.Image due_image;
Expand Down Expand Up @@ -117,7 +117,7 @@ public class Views.List : Gtk.Grid {

scrolled_window = new Widgets.ScrolledWindow (content_clamp);

attach (scrolled_window, 0, 0);
child = scrolled_window;
update_request ();
add_sections ();

Expand Down

0 comments on commit b6f51b4

Please sign in to comment.