Add toot deletion

This commit is contained in:
bleakgrey 2018-05-22 15:47:25 +03:00
parent b6d265e6a8
commit 2e45aa825e
2 changed files with 18 additions and 0 deletions

View File

@ -119,5 +119,15 @@ public class Tootle.Status {
});
Tootle.network.queue (msg);
}
public void poof (){
var msg = new Soup.Message("DELETE", "%s/api/v1/statuses/%lld".printf (Tootle.settings.instance_url, id));
msg.priority = Soup.MessagePriority.HIGH;
msg.finished.connect (() => {
Tootle.app.toast (_("Poof!"));
Tootle.network.status_removed (this.id);
});
Tootle.network.queue (msg);
}
}

View File

@ -261,6 +261,8 @@ public class Tootle.StatusWidget : Gtk.EventBox {
menu.destroy ();
});
var item_delete = new Gtk.MenuItem.with_label (_("Delete"));
item_delete.activate.connect (() => status.poof ());
var item_open_link = new Gtk.MenuItem.with_label (_("Open in Browser"));
item_open_link.activate.connect (() => Utils.open_url (status.url));
var item_copy_link = new Gtk.MenuItem.with_label (_("Copy Link"));
@ -270,6 +272,12 @@ public class Tootle.StatusWidget : Gtk.EventBox {
var sanitized = Utils.escape_html (status.content);
Utils.copy (sanitized);
});
if (this.status.is_owned ()) {
menu.add (item_delete);
menu.add (new Gtk.SeparatorMenuItem ());
}
menu.add (item_open_link);
menu.add (new Gtk.SeparatorMenuItem ());
menu.add (item_copy_link);