Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/API/GroupedNotificationsResults.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,26 @@ public class Tuba.API.GroupedNotificationsResults : Entity {
case InstanceAccount.KIND_FOLLOW:
case InstanceAccount.KIND_ADMIN_SIGNUP:
return create_basic_card ();
default:
case InstanceAccount.KIND_MENTION:
case InstanceAccount.KIND_REBLOG:
case InstanceAccount.KIND_FAVOURITE:
case InstanceAccount.KIND_POLL:
case InstanceAccount.KIND_FOLLOW_REQUEST:
case InstanceAccount.KIND_REMOTE_REBLOG:
case InstanceAccount.KIND_EDITED:
case InstanceAccount.KIND_REPLY:
case InstanceAccount.KIND_SEVERED_RELATIONSHIPS:
case InstanceAccount.KIND_ADMIN_REPORT:
case InstanceAccount.KIND_STATUS:
case InstanceAccount.KIND_PLEROMA_REACTION:
case InstanceAccount.KIND_REACTION:
case InstanceAccount.KIND_ANNUAL_REPORT:
case InstanceAccount.KIND_MODERATION_WARNING:
case InstanceAccount.KIND_QUOTE:
case InstanceAccount.KIND_QUOTE_UPDATE:
return new Widgets.GroupedNotification (this);
default:
return base.to_widget ();
}
}

Expand Down
29 changes: 25 additions & 4 deletions src/API/Notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,30 @@ public class Tuba.API.Notification : Entity, Widgetizable {
_("Review your year's highlights and memorable moments on the Fediverse!")
)
);
default:
case InstanceAccount.KIND_MENTION:
case InstanceAccount.KIND_REBLOG:
case InstanceAccount.KIND_FAVOURITE:
case InstanceAccount.KIND_POLL:
case InstanceAccount.KIND_REMOTE_REBLOG:
case InstanceAccount.KIND_EDITED:
case InstanceAccount.KIND_REPLY:
case InstanceAccount.KIND_STATUS:
case InstanceAccount.KIND_PLEROMA_REACTION:
case InstanceAccount.KIND_REACTION:
case InstanceAccount.KIND_QUOTE:
case InstanceAccount.KIND_QUOTE_UPDATE:
return new Widgets.Notification (this);
default:
return create_basic_card (
"tuba-background-app-ghost-symbolic",
// translators: the variable is a string notification type
_("Unknown notification: %s").printf (kind),
false
);
}
}

private Gtk.Widget create_basic_card (string icon_name, string label) {
private Gtk.Widget create_basic_card (string icon_name, string label, bool can_open = true) {
var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 16) {
margin_top = 8,
margin_bottom = 8,
Expand All @@ -165,12 +183,13 @@ public class Tuba.API.Notification : Entity, Widgetizable {

var row = new Widgets.ListBoxRowWrapper () {
child = box,
activatable = can_open
};
row.open.connect (open);
if (can_open) row.open.connect (open);
return row;
}

public virtual async GLib.Notification to_toast (InstanceAccount issuer, int others = 0) {
public virtual async GLib.Notification? to_toast (InstanceAccount issuer, int others = 0) {
Tuba.InstanceAccount.Kind res_kind;
bool should_show_buttons = issuer == accounts.active;

Expand All @@ -188,6 +207,8 @@ public class Tuba.API.Notification : Entity, Widgetizable {
}

issuer.describe_kind (kind, out res_kind, kind_actor_name, null, other_data);
if (res_kind.description == null) return null;

var toast = new GLib.Notification (res_kind.description);
if (status != null) {
var body = "";
Expand Down
3 changes: 2 additions & 1 deletion src/Services/Accounts/InstanceAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,8 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
sent_notifications.set (id, others);

obj.to_toast.begin (this, others, (_obj, res) => {
app.send_notification (id, obj.to_toast.end (res));
GLib.Notification? notification = obj.to_toast.end (res);
if (notification != null) app.send_notification (id, notification);
});
}

Expand Down