Skip to content

Commit

Permalink
feat(status): reply kind indicator if there's no other (#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Apr 8, 2024
1 parent 556df86 commit ce9a6db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/Services/Accounts/InstanceAccount.vala
Expand Up @@ -14,6 +14,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
public const string KIND_FOLLOW_REQUEST = "follow_request";
public const string KIND_REMOTE_REBLOG = "__remote-reblog";
public const string KIND_EDITED = "update";
public const string KIND_REPLY = "tuba_reply";

public string uuid { get; set; }
public string? backend { set; get; }
Expand Down Expand Up @@ -168,7 +169,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
}

public virtual void describe_kind (
string kind,
string? kind,
out Kind result,
string? actor_name = null,
string? callback_url = null
Expand Down Expand Up @@ -230,6 +231,13 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
null
};
break;
case KIND_REPLY:
result = {
"tuba-reply-sender-symbolic",
_("In Reply"),
null
};
break;
default:
result = {
null,
Expand Down
1 change: 1 addition & 0 deletions src/Views/Thread.vala
Expand Up @@ -207,6 +207,7 @@ public class Tuba.Views.Thread : Views.ContentBase, AccountHolder {
widget_status.reply_cb = on_replied;
widget_status.enable_thread_lines = true;
widget_status.content.selectable = true;
widget_status.kind = null;

if (((API.Status) obj).id == root_status.id) {
#if !USE_LISTVIEW
Expand Down
16 changes: 12 additions & 4 deletions src/Widgets/Status.vala
Expand Up @@ -205,8 +205,12 @@
status: status
);

if (kind == null && status.reblog != null) {
kind = InstanceAccount.KIND_REMOTE_REBLOG;
if (kind == null) {
if (status.reblog != null) {
kind = InstanceAccount.KIND_REMOTE_REBLOG;
} else if (status.in_reply_to_id != null || status.in_reply_to_account_id != null) {
kind = InstanceAccount.KIND_REPLY;
}
}

init_menu_button ();
Expand Down Expand Up @@ -432,8 +436,10 @@
Tuba.InstanceAccount.Kind res_kind;
accounts.active.describe_kind (this.kind, out res_kind, this.kind_instigator.display_name, this.kind_instigator.url);

if (header_button_activate > 0) header_button.disconnect (header_button_activate);
if (res_kind.icon == null) {
// status_box.margin_top = 18;
header_icon.visible = header_button.visible = false;
return;
};

Expand Down Expand Up @@ -471,9 +477,11 @@
header_label.label = res_kind.description;
header_kind_url = res_kind.url;

if (header_button_activate > 0) header_button.disconnect (header_button_activate);
if (header_kind_url != null)
if (header_kind_url != null) {
header_button_activate = header_button.clicked.connect (on_header_button_clicked);
} else {
header_button_activate = header_button.clicked.connect (on_open);
}
}

private void on_header_button_clicked () {
Expand Down

0 comments on commit ce9a6db

Please sign in to comment.