Default subreddit post sorting. Closes #166

This commit is contained in:
spikecodes
2021-03-25 21:41:58 -07:00
parent 2533e8cef5
commit 6a7f725c12
6 changed files with 16 additions and 20 deletions

View File

@@ -16,19 +16,6 @@ struct SettingsTemplate {
prefs: Preferences,
}
#[derive(serde::Deserialize, Default, Debug)]
#[serde(default)]
pub struct Form {
theme: Option<String>,
front_page: Option<String>,
layout: Option<String>,
wide: Option<String>,
comment_sort: Option<String>,
show_nsfw: Option<String>,
redirect: Option<String>,
subscriptions: Option<String>,
}
// FUNCTIONS
// Retrieve cookies from request "Cookie" header
@@ -63,7 +50,7 @@ pub async fn set(req: Request<Body>) -> Result<Response<Body>, String> {
let mut res = redirect("/settings".to_string());
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "show_nsfw", "subscriptions"];
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "post_sort", "show_nsfw", "subscriptions"];
for name in names {
match form.get(name) {
@@ -98,7 +85,7 @@ pub async fn restore(req: Request<Body>) -> Result<Response<Body>, String> {
let form = url::form_urlencoded::parse(query).collect::<HashMap<_, _>>();
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "show_nsfw", "subscriptions"];
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "post_sort", "show_nsfw", "subscriptions"];
let path = match form.get("redirect") {
Some(value) => format!("/{}/", value),