Simplify sub list editing.

This commit is contained in:
Matthew Crossman 2021-01-31 12:25:07 +11:00
parent b527735f6f
commit f14639ee00
No known key found for this signature in database
GPG Key ID: C6B942B019794CC2

View File

@ -80,13 +80,8 @@ pub async fn subscriptions(req: HttpRequest) -> HttpResponse {
// Modify sub list based on action // Modify sub list based on action
if action == "subscribe" { if action == "subscribe" {
if sub_list.is_empty() { sub_list.push(sub_name);
sub_list = Vec::new(); sub_list.sort();
sub_list.push(sub_name);
} else if !sub_list.contains(&sub_name) {
sub_list.push(sub_name);
sub_list.sort();
}
} else { } else {
sub_list.retain(|s| s != &sub_name); sub_list.retain(|s| s != &sub_name);
} }