diff --git a/Cargo.lock b/Cargo.lock index d2da38c..dbacf7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -751,6 +751,16 @@ dependencies = [ "syn", ] +[[package]] +name = "dashmap" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" +dependencies = [ + "cfg-if 1.0.0", + "num_cpus", +] + [[package]] name = "data-encoding" version = "2.3.2" @@ -1057,12 +1067,13 @@ dependencies = [ [[package]] name = "http-client" -version = "6.2.0" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "010092b71b94ee49293995625ce7a607778b8b4099c8088fa84fd66bd3e0f21c" +checksum = "518cdefb188f1e14c60151ca4ee1c186c9b6e0d7047c334e53478d3d9f2b0dfa" dependencies = [ "async-std", "async-trait", + "dashmap", "http-types", "isahc", "log", @@ -1510,9 +1521,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] @@ -1896,9 +1907,9 @@ dependencies = [ [[package]] name = "tap" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "thiserror" @@ -2289,4 +2300,4 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" name = "wyz" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" \ No newline at end of file +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" diff --git a/src/subreddit.rs b/src/subreddit.rs index ceff7c3..ef8ed3f 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -90,17 +90,17 @@ pub async fn subscriptions(req: Request<()>) -> tide::Result { let mut sub_list = prefs(req).subs; // Find each subreddit name (separated by '+') in sub parameter - let split = sub.split('+'); - - // Modify sub list based on action - if action.contains(&"subscribe".to_string()) && !sub_list.contains(&sub) { - // Add each sub name to the subscribed list - split.map(|part| sub_list.push(part.to_owned())).min(); - // Reorder sub names alphabettically - sub_list.sort_by_key(|a| a.to_lowercase()) - } else if action.contains(&"unsubscribe".to_string()) { - // Remove sub name from subscribed list - sub_list.retain(|s| s != &sub); + for part in sub.split('+') { + // Modify sub list based on action + if action.contains(&"subscribe".to_string()) && !sub_list.contains(&part.to_owned()) { + // Add each sub name to the subscribed list + sub_list.push(part.to_owned()); + // Reorder sub names alphabettically + sub_list.sort_by_key(|a| a.to_lowercase()) + } else if action.contains(&"unsubscribe".to_string()) { + // Remove sub name from subscribed list + sub_list.retain(|s| s != part); + } } // Redirect back to subreddit diff --git a/static/style.css b/static/style.css index 5094889..45ad3ed 100644 --- a/static/style.css +++ b/static/style.css @@ -285,6 +285,10 @@ aside { margin-top: 20px; } +#multisub { + margin-bottom: 20px; +} + .subscribe, .unsubscribe { padding: 10px 20px; border-radius: 5px; diff --git a/templates/subreddit.html b/templates/subreddit.html index d6c5667..11440ec 100644 --- a/templates/subreddit.html +++ b/templates/subreddit.html @@ -39,6 +39,12 @@ {% endif %} + {% if sub.name.contains("+") %} +
+ +
+ {% endif %} +
{% for post in posts %} {% if !(post.flags.nsfw && prefs.show_nsfw != "on") %}