Prevent adding duplicate subs.

This commit is contained in:
Matthew Crossman 2021-01-31 12:45:19 +11:00
parent a301f1ecb6
commit 9b7cd1da5a
No known key found for this signature in database
GPG Key ID: C6B942B019794CC2

View File

@ -79,10 +79,10 @@ pub async fn subscriptions(req: HttpRequest) -> HttpResponse {
let mut sub_list = prefs(req.to_owned()).subs;
// Modify sub list based on action
if action == "subscribe" {
if action == "subscribe" && !sub_list.contains(&sub_name) {
sub_list.push(sub_name);
sub_list.sort();
} else {
} else if action == "unsubscribe" {
sub_list.retain(|s| s != &sub_name);
}