Skip to content

Commit e46f649

Browse files
authored
fix(instanceaccount): allow updating notification count more than once (#1063)
1 parent 44369d0 commit e46f649

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/Services/Accounts/InstanceAccount.vala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
7272
gather_instance_info ();
7373
gather_instance_custom_emojis ();
7474
check_announcements ();
75-
init_notifications ();
75+
check_notifications ();
7676
}
7777

7878
construct {
@@ -357,7 +357,6 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
357357
public int unread_count { get; set; default = 0; }
358358
public int last_read_id { get; set; default = 0; }
359359
public int last_received_id { get; set; default = 0; }
360-
private bool passed_init_notifications = false;
361360

362361
public class StatusContentType : Object {
363362
public string mime { get; construct set; }
@@ -482,9 +481,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
482481
}
483482

484483
public void init_notifications () {
485-
if (passed_init_notifications) return;
486-
487-
new Request.GET ("/api/v1/notifications")
484+
new Request.GET (@"/api/v1/notifications$(Views.Notifications.get_notifications_excluded_types_query_param ())")
488485
.with_account (this)
489486
.with_param ("min_id", last_read_id.to_string ())
490487
.then ((in_stream) => {
@@ -496,7 +493,6 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
496493
last_received_id = int.parse (array.get_object_element (0).get_string_member_with_default ("id", "-1"));
497494
}
498495
}
499-
passed_init_notifications = true;
500496
})
501497
.exec ();
502498
}
@@ -510,7 +506,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
510506
if (!root.has_member ("notifications")) return;
511507
var notifications = root.get_object_member ("notifications");
512508
last_read_id = int.parse (notifications.get_string_member_with_default ("last_read_id", "-1"));
513-
if (!passed_init_notifications) init_notifications ();
509+
init_notifications ();
514510
})
515511
.exec ();
516512
}

src/Views/Notifications.vala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,20 @@ public class Tuba.Views.Notifications : Views.Timeline, AccountHolder, Streamabl
187187
: null;
188188
}
189189

190+
public static string get_notifications_excluded_types_query_param () {
191+
if (settings.notification_filters.length == 0) return "";
192+
193+
return @"?exclude_types[]=$(string.joinv ("&exclude_types[]=", settings.notification_filters))";
194+
}
195+
190196
public void filters_changed (bool refresh = true) {
191197
string new_url = "/api/v1/notifications";
192198

193199
if (settings.notification_filters.length == 0) {
194200
this.is_all = true;
195201
} else {
196202
this.is_all = false;
197-
new_url += @"?exclude_types[]=$(string.joinv ("&exclude_types[]=", settings.notification_filters))";
203+
new_url += get_notifications_excluded_types_query_param ();
198204
}
199205

200206
if (new_url == this.url) return;

0 commit comments

Comments
 (0)