Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Widgets.Account): reactive relationships #1001

Merged
merged 1 commit into from
Jun 13, 2024
Merged
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
1 change: 1 addition & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace Tuba {
public Streams app_streams { get {return Tuba.streams; } }

public signal void refresh ();
public signal void relationship_invalidated (API.Relationship new_relationship);
public signal void toast (string title, uint timeout = 5);

#if DEV_MODE
Expand Down
12 changes: 11 additions & 1 deletion src/Widgets/Account.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ public class Tuba.Widgets.Account : Gtk.ListBoxRow {
debug ("Destroying Widgets.Account");
}

public class RelationshipButton : Tuba.Widgets.RelationshipButton {
public class RelationshipButton : Widgets.RelationshipButton {
construct {
app.relationship_invalidated.connect (on_relationship_invalidated_global);
}

private void on_relationship_invalidated_global (API.Relationship new_relationship) {
if (rs == null || rs.id != new_relationship.id) return;

rs = new_relationship;
}

public override void invalidate () {
if (rs == null || rs.domain_blocking) {
visible = false;
Expand Down
2 changes: 2 additions & 0 deletions src/Widgets/ProfileCover.vala
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ protected class Tuba.Widgets.Cover : Gtk.Box {
note_row.visible = _mini ? rs.note != "" : rs.note != null;
if (note_row.visible) note_entry_row.text = rs.note;

if (!_mini) app.relationship_invalidated (rs);

rs_invalidated ();
update_aria ();
}
Expand Down
1 change: 1 addition & 0 deletions src/Widgets/RelationshipButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Tuba.Widgets.RelationshipButton : Gtk.Button {

protected void on_bound () {
if (rs != null) {
rs.invalidated.disconnect (invalidate);
rs.invalidated.connect (invalidate);
}
invalidate ();
Expand Down
Loading