Skip to content

Commit

Permalink
feat(home): new posts badge
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Feb 4, 2024
1 parent 072a3c9 commit f95deb8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
color: @text_view_bg;
}

.ttl-sidebar .badge.no-attention {
background: alpha(@sidebar_fg_color, .4);
}

.font-bold {
font-weight: bold;
}
Expand Down
1 change: 1 addition & 0 deletions src/Services/Accounts/Mastodon/Account.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Tuba.Mastodon.Account : InstanceAccount {

icon = "user-home-symbolic",
title = _("Home"),
needs_attention = false,
open_func = win => {
// win.open_view (new Views.Main ());
// win.back();
Expand Down
1 change: 1 addition & 0 deletions src/Services/Accounts/Places.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Tuba.Place : Object {
public bool separated { get; set; default = false; }
public bool selectable { get; set; default = true; }
public bool visible { get; set; default = true; }
public bool needs_attention { get; construct set; default=true; }

[CCode (has_target = false)]
public delegate void OpenFunc (Dialogs.MainWindow window);
Expand Down
5 changes: 5 additions & 0 deletions src/Views/Home.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ public class Tuba.Views.Home : Views.Timeline {
url = "/api/v1/timelines/home";
label = _("Home");
icon = "user-home-symbolic";
badge_number = 0;
needs_attention = false;

scroll_to_top_rev.margin_end = 32;
scroll_to_top_rev.margin_bottom = 24;
Expand Down Expand Up @@ -42,6 +44,9 @@ public class Tuba.Views.Home : Views.Timeline {
if (!app.is_mobile)
compose_button_rev.reveal_child = true;
});

this.bind_property ("entity-queue-size", this, "badge-number", BindingFlags.SYNC_CREATE);
this.bind_property ("badge-number", Tuba.Mastodon.Account.PLACE_HOME, "badge", BindingFlags.SYNC_CREATE);
}

void toggle_scroll_to_top_margin () {
Expand Down
2 changes: 2 additions & 0 deletions src/Views/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
});

place.bind_property ("selectable", this, "selectable", BindingFlags.SYNC_CREATE);

if (!place.needs_attention) badge.add_css_class ("no-attention");
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/Views/Timeline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
public string? page_prev { get; set; }
#if !USE_LISTVIEW
Entity[] entity_queue = {};
protected int entity_queue_size { get; set; default=0; }
#endif

private Gtk.Spinner pull_to_refresh_spinner;
Expand Down Expand Up @@ -120,6 +121,7 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
#if !USE_LISTVIEW
content.bind_model (null, null);
entity_queue = {};
entity_queue_size = 0;
#endif
}

Expand Down Expand Up @@ -227,6 +229,7 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
public virtual void on_refresh () {
#if !USE_LISTVIEW
entity_queue = {};
entity_queue_size = 0;
#endif
scrolled.vadjustment.value = 0;
status_button.sensitive = false;
Expand Down Expand Up @@ -281,6 +284,7 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase

if (use_queue && scrolled.vadjustment.value > 1000) {
entity_queue += entity;
entity_queue_size += 1;
return;
}

Expand All @@ -297,6 +301,7 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
model.splice (0, 0, (Object[])entity_queue);

entity_queue = {};
entity_queue_size = 0;
}
#endif

Expand Down

0 comments on commit f95deb8

Please sign in to comment.