fix: wrong comments when editing

This commit is contained in:
mrilyew 2025-05-24 22:20:23 +03:00 committed by Alexander Minkin
parent 3727e4cd40
commit 8f9a303ce9
2 changed files with 10 additions and 3 deletions

View file

@ -149,7 +149,7 @@ final class InternalAPIPresenter extends OpenVKPresenter
{ {
if ($_SERVER["REQUEST_METHOD"] !== "POST") { if ($_SERVER["REQUEST_METHOD"] !== "POST") {
header("HTTP/1.1 405 Method Not Allowed"); header("HTTP/1.1 405 Method Not Allowed");
exit("ты‍ не по адресу"); $this->redirect("/");
} }
$type = $this->queryParam("type", false); $type = $this->queryParam("type", false);
@ -168,7 +168,7 @@ final class InternalAPIPresenter extends OpenVKPresenter
if ($type == 'post') { if ($type == 'post') {
$this->template->_template = 'components/post.xml'; $this->template->_template = 'components/post.xml';
$this->template->post = $post; $this->template->post = $post;
$this->template->commentSection = true; $this->template->commentSection = $this->queryParam("from_page") == "another";
} elseif ($type == 'comment') { } elseif ($type == 'comment') {
$this->template->_template = 'components/comment.xml'; $this->template->_template = 'components/comment.xml';
$this->template->comment = $post; $this->template->comment = $post;

View file

@ -1125,7 +1125,14 @@ u(document).on("click", "#editPost", async (e) => {
return return
} }
const new_post_html = await (await fetch(`/iapi/getPostTemplate/${id[0]}_${id[1]}?type=${type}`, { let is_at_post_page = false
try {
if(location.pathname.indexOf("wall") != -1 && location.pathname.split("_").length == 2) {
is_at_post_page = true
}
} catch(e) {}
const new_post_html = await (await fetch(`/iapi/getPostTemplate/${id[0]}_${id[1]}?type=${type}&from_page=${is_at_post_page ? "post" : "another"}`, {
'method': 'POST' 'method': 'POST'
})).text() })).text()
u(ev.target).removeClass('lagged') u(ev.target).removeClass('lagged')