Skip to content

Commit

Permalink
feat(Bubble): Chuckya support (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Dec 20, 2024
1 parent 9a50c1a commit ccd8816
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/API/Instance.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Tuba.API.Instance : Entity {
public Gee.ArrayList<Rule>? rules { get; set; }

public bool tuba_can_translate { get; set; default=false; }
public int8 tuba_mastodon_version { get; set; default=0; }
public API.InstanceV2.APIVersions tuba_api_versions { get; set; default= new API.InstanceV2.APIVersions (); }

public override Type deserialize_array_type (string prop) {
switch (prop) {
Expand All @@ -44,6 +44,8 @@ public class Tuba.API.Instance : Entity {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.features != null) {
return "bubble_timeline" in pleroma.metadata.features;
} else if (tuba_api_versions.chuckya > 0) {
return true;
}

return false;
Expand Down
1 change: 1 addition & 0 deletions src/API/InstanceV2.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Tuba.API.InstanceV2 : Entity {

public class APIVersions : Entity {
public int8 mastodon { get; set; default = 0; }
public int8 chuckya { get; set; default = 0; }
}

public Configuration configuration { get; set; default = null; }
Expand Down
7 changes: 4 additions & 3 deletions src/Services/Accounts/InstanceAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,14 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
this.instance_info.tuba_can_translate = instance_v2.configuration.translation.enabled;

if (instance_v2.api_versions != null && instance_v2.api_versions.mastodon > 0) {
this.instance_info.tuba_mastodon_version = instance_v2.api_versions.mastodon;
this.instance_info.tuba_api_versions = instance_v2.api_versions;
this.probably_has_notification_filters = true;

if (this.instance_info.tuba_mastodon_version > 1) gather_annual_report ();
if (this.instance_info.tuba_api_versions.mastodon > 1) gather_annual_report ();
}
}

bump_sidebar_items ();
})
.exec ();
}
Expand All @@ -557,7 +559,6 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
return;
}


new Request.GET (@"/api/v1/annual_reports/$(year)")
.with_account (accounts.active)
.then ((in_stream) => {
Expand Down
10 changes: 9 additions & 1 deletion src/Views/Bubble.vala
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
public class Tuba.Views.Bubble : Views.Timeline {
construct {
url = "/api/v1/timelines/bubble";
url = accounts.active.instance_info.tuba_api_versions.chuckya > 0
? "/api/v1/timelines/public?bubble=true&only_media=false"
: "/api/v1/timelines/bubble";
label = "Bubble"; // NOTE: Leave untranslated for now
icon = "tuba-fish-symbolic";
is_public = true;
}

public override string? get_stream_url () {
return account != null && accounts.active.instance_info.tuba_api_versions.chuckya > 0
? @"$(account.instance)/api/v1/streaming?stream=public:bubble&access_token=$(account.access_token)"
: null;
}
}
4 changes: 3 additions & 1 deletion src/Widgets/AccountSuggestions.vala
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public class Tuba.Widgets.AccountSuggestions : Gtk.ListBoxRow {
if (widgets.size > 0) {
this.visible = true;
populate_account_suggestions_relationships (widgets);
};
} else {
this.visible = false;
}
on_page_changed ();
})
.on_error (() => {
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/PreviewCardExplore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class Tuba.Widgets.PreviewCardExplore : Gtk.ListBoxRow {
css_classes = { "caption" }
};

if (accounts.active.instance_info.tuba_mastodon_version >= 1) {
if (accounts.active.instance_info.tuba_api_versions.mastodon >= 1) {
Gtk.Button discussions_button = new Gtk.Button () {
margin_top = 6,
child = used_times_label,
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/ProfileCover.vala
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ protected class Tuba.Widgets.Cover : Gtk.Box {
note_row.sensitive = false;
} else if (!is_self) {
moved_btn.clicked.connect (on_moved_btn_clicked);
if (accounts.active.instance_info != null && accounts.active.instance_info.tuba_mastodon_version > 0) {
if (accounts.active.instance_info != null && accounts.active.instance_info.tuba_api_versions.mastodon > 0) {
GLib.Idle.add (populate_mutuals);
}
}
Expand Down

0 comments on commit ccd8816

Please sign in to comment.