Tooth/src/API/Conversation.vala

31 lines
734 B
Vala
Raw Normal View History

2022-11-13 20:57:43 +00:00
public class Tooth.API.Conversation : Entity, Widgetizable {
2020-06-03 15:06:11 +00:00
2020-08-01 21:47:22 +00:00
public string id { get; set; }
public Gee.ArrayList<API.Account> accounts { get; set; }
2020-06-03 15:06:11 +00:00
public bool unread { get; set; default = false; }
2020-08-01 21:47:22 +00:00
public API.Status? last_status { get; set; default = null; }
public override Gtk.Widget to_widget () {
return new Widgets.Conversation (this);
}
public override void open () {
var view = new Views.Thread (last_status.formal);
2021-07-23 11:41:03 +00:00
app.main_window.open_view (view);
2020-08-01 21:47:22 +00:00
if (unread)
mark_read ();
}
public void mark_read () {
new Request.POST (@"/api/v1/conversations/$id/read")
2022-11-13 20:57:43 +00:00
.with_account (Tooth.accounts.active)
2020-08-01 21:47:22 +00:00
.then (() => {
unread = false;
})
.on_error (() => {})
.exec ();
}
2020-06-03 15:06:11 +00:00
}