Skip to content

Commit

Permalink
fix #1409
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Aug 28, 2024
1 parent 76f0099 commit 82800ed
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
14 changes: 13 additions & 1 deletion core/Objects/Label.vala
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public class Objects.Label : Objects.BaseObject {
return generator.to_data (null);
}

public void delete_label (Gtk.Window window) {
public async void delete_label (Gtk.Window window) {
var dialog = new Adw.AlertDialog (
_("Delete Label %s".printf (name)),
_("This can not be undone")
Expand All @@ -220,6 +220,18 @@ public class Objects.Label : Objects.BaseObject {
Services.Todoist.get_default ().delete.end (res);
Services.Store.instance ().delete_label (this);
});
} else if (source_type == SourceType.CALDAV) {
loading = true;
foreach (Objects.Item item in Services.Store.instance ().get_items_by_label (this, false)) {
item.delete_item_label (id);
Services.CalDAV.Core.get_default ().add_task.begin (item, true, (obj, res) => {
if (Services.CalDAV.Core.get_default ().add_task.end (res).status) {
Services.Store.instance ().update_item (item);
}
});
}

Services.Store.instance ().delete_label (this);
} else {
Services.Store.instance ().delete_label (this);
}
Expand Down
7 changes: 7 additions & 0 deletions core/Services/CalDAV/Core.vala
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ public class Services.CalDAV.Core : GLib.Object {
}

public async void sync_tasklist (Objects.Project project) {
if (project.is_deck) {
return;
}

project.loading = true;
yield update_tasklist_detail (project);

var url = "%s/calendars/%s/%s".printf (project.source.caldav_data.server_url, project.source.caldav_data.username, project.id);
Expand Down Expand Up @@ -367,6 +372,8 @@ public class Services.CalDAV.Core : GLib.Object {
} catch (Error e) {
debug (e.message);
}

project.loading = false;
}

private async string? get_vtodo_by_url (Objects.Project project, string task_ics) {
Expand Down
4 changes: 4 additions & 0 deletions data/resources/stylesheet/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,10 @@ checkbutton.theme-selector radio:checked {
border-radius: 1px;
}

.icon-color {
color: @colorAccent;
}

.drop-area {
background-color: alpha(#1e63ec, 0.25);
border-radius: 6px;
Expand Down
16 changes: 9 additions & 7 deletions src/Layouts/LabelRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
private Gtk.Label count_label;
private Gtk.Revealer count_revealer;
private Gtk.Revealer main_revealer;
private Gtk.Grid widget_color;
private Gtk.Image widget_color;
private Gtk.Box handle_grid;

public LabelRow (Objects.Label label) {
Expand All @@ -36,13 +36,11 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
}

construct {
css_classes = { "selectable-item", "transition" };

widget_color = new Gtk.Grid () {
css_classes = { "row", "transition", "no-padding" };

widget_color = new Gtk.Image.from_icon_name ("tag-outline-symbolic") {
css_classes = { "icon-color" },
valign = Gtk.Align.CENTER,
height_request = 19,
width_request = 19,
css_classes = { "circle-color" }
};

name_label = new Gtk.Label (label.name) {
Expand Down Expand Up @@ -122,6 +120,10 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
label.loading_change.connect (() => {
loading_button.is_loading = label.loading;
});

loading_button.clicked.connect (() => {
Services.EventBus.get_default ().pane_selected (PaneType.LABEL, label.id);
});
}

public void update_request () {
Expand Down
15 changes: 3 additions & 12 deletions src/Layouts/ProjectRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public class Layouts.ProjectRow : Gtk.ListBoxRow {
menu_box.append (duplicate_item);
menu_box.append (new Widgets.ContextMenu.MenuSeparator ());

if (project.source_type == SourceType.CALDAV) {
if (project.source_type == SourceType.CALDAV && !project.is_deck) {
menu_box.append (refresh_item);
menu_box.append (new Widgets.ContextMenu.MenuSeparator ());
}
Expand Down Expand Up @@ -728,12 +728,7 @@ public class Layouts.ProjectRow : Gtk.ListBoxRow {

refresh_item.clicked.connect (() => {
menu_popover.popdown ();

if (project.sync_id == "") {
is_loading = true;
} else {
sync_project ();
}
sync_project ();
});

delete_item.clicked.connect (() => {
Expand Down Expand Up @@ -763,11 +758,7 @@ public class Layouts.ProjectRow : Gtk.ListBoxRow {
}

private void sync_project () {
is_loading = true;
Services.CalDAV.Core.get_default ().sync_tasklist.begin (project, (obj, res) => {
Services.CalDAV.Core.get_default ().sync_tasklist.end (res);
is_loading = false;
});
Services.CalDAV.Core.get_default ().sync_tasklist.begin (project);
}

private void update_listbox_revealer () {
Expand Down

0 comments on commit 82800ed

Please sign in to comment.