Forum: answers to me as the only count, reply box in the branch, keyboard-safe inputs
- The "Követett" tab becomes "Válaszok": its count is the unread answers to the member (a reply to their post, a first-level reply in their thread, or a post naming them), listed on /forum/valaszok with "Mind olvasott"; the followed threads are its second view. The other counts are gone from the menu; listeners see the waiting threads on their card on the front page. - Replying to a post opens the box at the bottom of its branch and scrolls there; another branch moves it (with the text typed so far). - Phones: while typing, the forum's bottom menu and floating bars step aside and the box with its send button is scrolled above the keyboard (KeyboardSafe, site-wide; Android resizes the page for the keyboard). - The "Meghallgató" badge is now "Kísérő", with a new icon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1044,8 +1044,8 @@ async fn mentions_listeners_supporters_and_who_is_here(pool: PgPool) {
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(app.get("/v1/forum/nav", Some(&bea)).await["waiting"], 1);
|
||||
assert!(app.get("/v1/forum/nav", Some(&cili)).await["waiting"].is_null());
|
||||
assert_eq!(app.get("/v1/forum/home", Some(&bea)).await["waiting"], 1);
|
||||
assert!(app.get("/v1/forum/home", Some(&cili)).await["waiting"].is_null());
|
||||
let shown = app.get(&format!("/v1/forum/threads/{thread}"), Some(&anna)).await;
|
||||
assert!(shown["posts"].as_array().unwrap().iter().all(|p| p["author"]["supporter"] == false));
|
||||
|
||||
@@ -1080,3 +1080,53 @@ async fn mentions_listeners_supporters_and_who_is_here(pool: PgPool) {
|
||||
.collect();
|
||||
assert!(here.contains(&"Zöldág".to_string()) && !here.contains(&"Csendesvíz".to_string()));
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn answers_to_the_member(pool: PgPool) {
|
||||
let app = TestApp::new(pool);
|
||||
let anna = app.member("anna@example.com", "Csendesvíz", &["user"]).await;
|
||||
let bea = app.member("bea@example.com", "Holdfény", &["user"]).await;
|
||||
let cili = app.member("cili@example.com", "Zöldág", &["user"]).await;
|
||||
let answers = |v: Value| -> Vec<(i64, String, bool)> {
|
||||
v["replies"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|r| (r["id"].as_i64().unwrap(), r["kind"].as_str().unwrap().to_string(), r["unread"] == true))
|
||||
.collect()
|
||||
};
|
||||
|
||||
// Anna's thread: Bea replies to it, Anna answers, Cili answers Anna's answer
|
||||
// (on the second level, under Bea's post) and names Bea elsewhere.
|
||||
let thread = app.thread(&anna, "torzsasztal", "Téli levesek").await;
|
||||
let first = app.reply(&bea, thread, "Gulyás.", None).await["id"].as_i64().unwrap();
|
||||
let second = app.reply(&anna, thread, "Az jó ötlet.", Some(first)).await["id"].as_i64().unwrap();
|
||||
let third = app.reply(&cili, thread, "Szerintem is.", Some(second)).await["id"].as_i64().unwrap();
|
||||
let fourth = app.reply(&cili, thread, "@Holdfény, babbal?", None).await["id"].as_i64().unwrap();
|
||||
|
||||
// Anna: Bea's reply in her thread (read once she answered it), Cili's answer
|
||||
// to her, and Cili's first-level post in her thread.
|
||||
assert_eq!(
|
||||
answers(app.get("/v1/forum/replies", Some(&anna)).await),
|
||||
vec![(fourth, "thread".into(), true), (third, "reply".into(), true), (first, "thread".into(), false)]
|
||||
);
|
||||
assert_eq!(app.get("/v1/forum/nav", Some(&anna)).await["replies"], 2);
|
||||
// Bea: Anna answered her; Cili named her. Cili's answer was to Anna, not to her.
|
||||
assert_eq!(
|
||||
answers(app.get("/v1/forum/replies", Some(&bea)).await),
|
||||
vec![(fourth, "mention".into(), true), (second, "reply".into(), true)]
|
||||
);
|
||||
// Nothing for Cili; a visitor gets nothing.
|
||||
assert_eq!(app.get("/v1/forum/nav", Some(&cili)).await["replies"], 0);
|
||||
assert!(app.get("/v1/forum/nav", None).await["replies"].is_null());
|
||||
|
||||
// Reading the thread clears them; so does "Mind olvasott".
|
||||
let (status, _) =
|
||||
app.call("POST", &format!("/v1/forum/threads/{thread}/read"), Some(&anna), json!({ "post_id": fourth })).await;
|
||||
assert_eq!(status, StatusCode::NO_CONTENT);
|
||||
assert_eq!(app.get("/v1/forum/nav", Some(&anna)).await["replies"], 0);
|
||||
let (status, _) = app.call("POST", "/v1/forum/replies/read", Some(&bea), Value::Null).await;
|
||||
assert_eq!(status, StatusCode::NO_CONTENT);
|
||||
assert_eq!(app.get("/v1/forum/nav", Some(&bea)).await["replies"], 0);
|
||||
assert_eq!(answers(app.get("/v1/forum/replies", Some(&bea)).await).len(), 2, "the list stays");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user