Add conversation muting
This commit is contained in:
parent
2e45aa825e
commit
19d4bbe98f
|
@ -11,9 +11,10 @@ public class Tootle.Status {
|
|||
public int64 reblogs_count;
|
||||
public int64 favourites_count;
|
||||
public string created_at;
|
||||
public bool reblogged;
|
||||
public bool favorited;
|
||||
public bool sensitive;
|
||||
public bool reblogged = false;
|
||||
public bool favorited = false;
|
||||
public bool sensitive = false;
|
||||
public bool muted = false;
|
||||
public StatusVisibility visibility;
|
||||
public Status? reblog;
|
||||
public Mention[]? mentions;
|
||||
|
@ -22,8 +23,6 @@ public class Tootle.Status {
|
|||
|
||||
public Status(int64 id) {
|
||||
this.id = id;
|
||||
this.reblogged = false;
|
||||
this.favorited = false;
|
||||
}
|
||||
|
||||
public Status get_formal (){
|
||||
|
@ -48,12 +47,14 @@ public class Tootle.Status {
|
|||
if (spoiler != "")
|
||||
status.spoiler_text = Utils.simplify_html (spoiler);
|
||||
|
||||
if(obj.has_member ("reblogged"))
|
||||
if (obj.has_member ("reblogged"))
|
||||
status.reblogged = obj.get_boolean_member ("reblogged");
|
||||
if(obj.has_member ("favourited"))
|
||||
if (obj.has_member ("favourited"))
|
||||
status.favorited = obj.get_boolean_member ("favourited");
|
||||
if (obj.has_member ("muted"))
|
||||
status.muted = obj.get_boolean_member ("muted");
|
||||
|
||||
if(obj.has_member ("reblog") && obj.get_null_member("reblog") != true)
|
||||
if (obj.has_member ("reblog") && obj.get_null_member("reblog") != true)
|
||||
status.reblog = Status.parse (obj.get_object_member ("reblog"));
|
||||
|
||||
Mention[]? _mentions = {};
|
||||
|
@ -120,6 +121,21 @@ public class Tootle.Status {
|
|||
Tootle.network.queue (msg);
|
||||
}
|
||||
|
||||
public void set_muted (bool mute = true){
|
||||
var action = mute ? "mute" : "unmute";
|
||||
var msg = new Soup.Message("POST", "%s/api/v1/statuses/%lld/%s".printf (Tootle.settings.instance_url, id, action));
|
||||
msg.priority = Soup.MessagePriority.HIGH;
|
||||
msg.finished.connect (() => {
|
||||
muted = mute;
|
||||
updated ();
|
||||
if (mute)
|
||||
Tootle.app.toast (_("Conversation muted"));
|
||||
else
|
||||
Tootle.app.toast (_("Conversation unmuted"));
|
||||
});
|
||||
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;
|
||||
|
|
|
@ -54,6 +54,7 @@ public class Tootle.NotificationWidget : Gtk.Grid {
|
|||
|
||||
if (notification.status != null){
|
||||
status_widget = new StatusWidget (ref notification.status);
|
||||
status_widget.is_notification = true;
|
||||
status_widget.button_press_event.connect(status_widget.open);
|
||||
status_widget.avatar.button_press_event.connect(status_widget.open_account);
|
||||
attach(status_widget, 1, 3, 3, 1);
|
||||
|
|
|
@ -5,6 +5,7 @@ using Granite;
|
|||
public class Tootle.StatusWidget : Gtk.EventBox {
|
||||
|
||||
public Status status;
|
||||
public bool is_notification = false;
|
||||
|
||||
public Gtk.Separator? separator;
|
||||
public Gtk.Grid grid;
|
||||
|
@ -261,6 +262,9 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
menu.destroy ();
|
||||
});
|
||||
|
||||
var is_muted = status.muted;
|
||||
var item_muting = new Gtk.MenuItem.with_label (is_muted ? _("Unmute Conversation") : _("Mute Conversation"));
|
||||
item_muting.activate.connect (() => status.set_muted (!is_muted));
|
||||
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"));
|
||||
|
@ -278,6 +282,8 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
menu.add (new Gtk.SeparatorMenuItem ());
|
||||
}
|
||||
|
||||
if (this.is_notification)
|
||||
menu.add (item_muting);
|
||||
menu.add (item_open_link);
|
||||
menu.add (new Gtk.SeparatorMenuItem ());
|
||||
menu.add (item_copy_link);
|
||||
|
|
Loading…
Reference in New Issue