diff --git a/migrations/20230427212229_update_triggers.up.sql b/migrations/20230427212229_update_triggers.up.sql index 40b37f7..5cca68a 100644 --- a/migrations/20230427212229_update_triggers.up.sql +++ b/migrations/20230427212229_update_triggers.up.sql @@ -28,7 +28,7 @@ create trigger if not exists update_last_updated_watch_quests after update on watch_quests when OLD.last_updated = NEW.last_updated or OLD.last_updated is null BEGIN - update watch_quests set last_updated = (select unixepoch()) where id=NEW.id; + update watch_quests set last_updated = (select unixepoch()) where watch=NEW.watch and user=NEW.user; END; create trigger if not exists update_last_updated_follows diff --git a/src/watches/handlers.rs b/src/watches/handlers.rs index 0798c94..8dfad91 100644 --- a/src/watches/handlers.rs +++ b/src/watches/handlers.rs @@ -34,6 +34,8 @@ const EMPTY_SEARCH_QUERY_STRUCT: SearchQuery = SearchQuery { search: None, }; +const CHECKMARK: &str = "✓"; + //-************************************************************************ // Error types for Watch creation //-************************************************************************ @@ -178,7 +180,7 @@ pub async fn post_add_watch_quest( add_watch_quest_impl(&pool, &quest) .await .map_err(|_| AddErrorKind::UnknownDBError)?; - let resp = "✓"; + let resp = checkmark(form.public); Ok(resp.into_response()) } else { let resp = Redirect::to("/login"); @@ -291,16 +293,17 @@ pub async fn get_watch_status( .map_err(|e| { tracing::error!("Got error from checking watch status: {e:?}"); })?; - let checkmark = "✓"; match quest { - Some(quest) if quest.watched => Ok(format!("{checkmark} watched").into_response()), - Some(quest) => { - let public = if quest.public { "public" } else { "private" }; - Ok(format!("{checkmark} ({public})").into_response()) - } + Some(quest) if quest.watched => Ok(format!("{CHECKMARK} watched").into_response()), + Some(quest) => Ok(checkmark(quest.public).into_response()), None => Ok(AddWatchButton { watch }.into_response()), } } else { Ok("Login to add".into_response()) } } + +fn checkmark(public: bool) -> String { + let public = if public { "public" } else { "private" }; + format!("{CHECKMARK} ({public})") +} diff --git a/templates/watch-search-result.html b/templates/watch-search-result.html index 37022b0..d7c765d 100644 --- a/templates/watch-search-result.html +++ b/templates/watch-search-result.html @@ -1,5 +1,5 @@ - {{watch.title}} + {{watch.title}} {{watch.kind}} {% call m::get_or_default(watch.year(), "when??") -%}