Fix new statuses not being published

This commit is contained in:
Bleak Grey 2020-05-30 12:21:50 +03:00
parent 55d566140c
commit f0326fec29
2 changed files with 19 additions and 7 deletions

View File

@ -3,7 +3,7 @@ using Gee;
public class Tootle.API.Status : GLib.Object { public class Tootle.API.Status : GLib.Object {
public int64 id { get; construct set; } public int64 id { get; construct set; } //TODO: IDs are no longer guaranteed to be numbers. Replace with strings.
public API.Account account { get; construct set; } public API.Account account { get; construct set; }
public string uri { get; set; } public string uri { get; set; }
public string? url { get; set; default = null; } public string? url { get; set; default = null; }
@ -94,7 +94,7 @@ public class Tootle.API.Status : GLib.Object {
} }
public Status.empty () { public Status.empty () {
Object (id: -1); Object (id: 0);
} }
public Status.from_account (API.Account account) { public Status.from_account (API.Account account) {

View File

@ -66,11 +66,19 @@ public class Tootle.Dialogs.Compose : Window {
} }
public Compose () { public Compose () {
Object (status: new API.Status.empty (), style_class: STYLE_CLASS_SUGGESTED_ACTION, label: _("Post")); Object (
status: new API.Status.empty (),
style_class: STYLE_CLASS_SUGGESTED_ACTION,
label: _("Post")
);
} }
public Compose.redraft (API.Status status) { public Compose.redraft (API.Status status) {
Object (status: status, style_class: STYLE_CLASS_DESTRUCTIVE_ACTION, label: _("Redraft")); Object (
status: status,
style_class: STYLE_CLASS_DESTRUCTIVE_ACTION,
label: _("Redraft")
);
} }
public Compose.reply (API.Status status) { public Compose.reply (API.Status status) {
@ -78,7 +86,11 @@ public class Tootle.Dialogs.Compose : Window {
template.in_reply_to_id = status.in_reply_to_id; template.in_reply_to_id = status.in_reply_to_id;
template.in_reply_to_account_id = status.in_reply_to_account_id; template.in_reply_to_account_id = status.in_reply_to_account_id;
template.content = status.formal.get_reply_mentions (); template.content = status.formal.get_reply_mentions ();
Object (status: template, style_class: STYLE_CLASS_SUGGESTED_ACTION, label: _("Reply")); Object (
status: template,
style_class: STYLE_CLASS_SUGGESTED_ACTION,
label: _("Reply")
);
visibility_popover.selected = status.visibility; visibility_popover.selected = status.visibility;
} }
@ -103,7 +115,7 @@ public class Tootle.Dialogs.Compose : Window {
visibility_button.sensitive = false; visibility_button.sensitive = false;
box.sensitive = false; box.sensitive = false;
if (status.id >= 0) { if (status.id > 0) {
info ("Removing old status..."); info ("Removing old status...");
status.poof (publish, on_error); status.poof (publish, on_error);
} }
@ -118,7 +130,7 @@ public class Tootle.Dialogs.Compose : Window {
status.spoiler_text = cw.text; status.spoiler_text = cw.text;
var req = new Request.POST ("/api/v1/statuses") var req = new Request.POST ("/api/v1/statuses")
.with_account () .with_account (accounts.active)
.with_param ("visibility", visibility_popover.selected.to_string ()) .with_param ("visibility", visibility_popover.selected.to_string ())
.with_param ("status", Html.uri_encode (status.content)); .with_param ("status", Html.uri_encode (status.content));