tidy watches handler, fix quest trigger.
This commit is contained in:
parent
dab2dc4081
commit
1e0a71f275
3 changed files with 12 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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 = "<style=\"background-color:green\">✓</style>";
|
||||
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("<a href='/login'>Login to add</a>".into_response())
|
||||
}
|
||||
}
|
||||
|
||||
fn checkmark(public: bool) -> String {
|
||||
let public = if public { "public" } else { "private" };
|
||||
format!("{CHECKMARK} ({public})")
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<tr id="watchlist-item-{{watch.id}}">
|
||||
<td><span class="watchtitle">{{watch.title}}</span></td>
|
||||
<td><span class="watchtitle"><a href="/watch/{{watch.id}}">{{watch.title}}</a></span></td>
|
||||
<td>{{watch.kind}}</td>
|
||||
<td> {% call m::get_or_default(watch.year(), "when??") -%}</td>
|
||||
<td>
|
||||
|
|
Loading…
Reference in a new issue