diff --git a/src/live_session.rs b/src/live_session.rs index c798540..c4d79ee 100644 --- a/src/live_session.rs +++ b/src/live_session.rs @@ -50,6 +50,11 @@ impl StreamHandler> for LiveSession { fn handle(&mut self, msg: Result, ctx: &mut Self::Context) { match msg { + Ok(WsMessage::Text(text)) => { + if text == "{\"type\":\"ping\"}" { + ctx.text("{\"type\":\"pong\"}"); + } + } Ok(WsMessage::Ping(data)) => ctx.pong(&data), Ok(WsMessage::Close(_)) => self.finished(ctx), _ => (), diff --git a/src/web/actions/edit_posts.rs b/src/web/actions/edit_posts.rs index af008ed..22b0368 100644 --- a/src/web/actions/edit_posts.rs +++ b/src/web/actions/edit_posts.rs @@ -1,4 +1,5 @@ use actix_web::{post, web::Data, HttpRequest, HttpResponse}; +use sqlx::query; use std::{collections::HashMap, fmt::Write}; use crate::{ @@ -50,6 +51,14 @@ pub async fn edit_posts( post.update_content(&ctx, content, content_nomarkup.into()) .await?; + query(&format!( + "UPDATE posts_{} SET quotes = array_remove(quotes, $1) WHERE $1 = ANY(quotes)", + post.board + )) + .bind(post.id) + .execute(ctx.db()) + .await?; + for quoted_post in quoted_posts { quoted_post.update_quotes(&ctx, post.id).await?; } diff --git a/src/web/staff/actions/update_boards.rs b/src/web/staff/actions/update_boards.rs index d757dc0..77f6b92 100755 --- a/src/web/staff/actions/update_boards.rs +++ b/src/web/staff/actions/update_boards.rs @@ -38,7 +38,7 @@ pub async fn update_boards( return Err(NekrochanError::BoardNameFormatError); } - if description.is_empty() || description.len() > 128 { + if description.len() > 128 { return Err(NekrochanError::DescriptionFormatError); } diff --git a/static/js/live.js b/static/js/live.js index 7808ffd..83c4750 100644 --- a/static/js/live.js +++ b/static/js/live.js @@ -21,10 +21,15 @@ $(function () { let ws_location = `${protocol}//${window.location.host}/live/${thread[0]}/${thread[1]}/${last_post}`; let ws = new WebSocket(ws_location); + let interval; ws.addEventListener("open", function (_) { $("#live-indicator").css("background-color", "lime"); $("#live-status").text("Připojeno pro nové příspěvky"); + + interval = setInterval(function () { + ws.send('{"type":"ping"}'); + }, 10000); }); ws.addEventListener("message", function (msg) { @@ -63,5 +68,6 @@ $(function () { ws.addEventListener("close", function (_) { $("#live-indicator").css("background-color", "red"); $("#live-status").text("Odpojeno, obnov stránku"); + clearInterval(interval); }); }); diff --git a/static/style.css b/static/style.css index b06d74a..42cc1c5 100755 --- a/static/style.css +++ b/static/style.css @@ -385,8 +385,8 @@ summary { } .thumb { - max-width: 200px; - max-height: 200px; + max-width: 150px; + max-height: 150px; } .post-content { diff --git a/templates/staff/boards.html b/templates/staff/boards.html index 53dbf4f..cd079c3 100755 --- a/templates/staff/boards.html +++ b/templates/staff/boards.html @@ -47,7 +47,7 @@ Popis - +