mirror of
https://github.com/openvk/openvk
synced 2025-04-23 08:33:02 +03:00
Add ctrl+enter + fix empty posts
This commit is contained in:
parent
2f05d81c02
commit
c3395f39bb
2 changed files with 18 additions and 4 deletions
|
@ -507,11 +507,10 @@ final class WallPresenter extends OpenVKPresenter
|
|||
if($_SERVER["REQUEST_METHOD"] !== "POST")
|
||||
$this->redirect("/id0");
|
||||
|
||||
if($this->postParam("type") == "post") {
|
||||
if($this->postParam("type") == "post")
|
||||
$post = $this->posts->get((int)$this->postParam("postid"));
|
||||
} else {
|
||||
else
|
||||
$post = (new Comments)->get((int)$this->postParam("postid"));
|
||||
}
|
||||
|
||||
if(!$post || $post->isDeleted())
|
||||
$this->returnJson(["error" => "Invalid post"]);
|
||||
|
@ -519,8 +518,18 @@ final class WallPresenter extends OpenVKPresenter
|
|||
if(!$post->canBeEditedBy($this->user->identity))
|
||||
$this->returnJson(["error" => "Access denied"]);
|
||||
|
||||
$attachmentsCount = sizeof(iterator_to_array($post->getChildren()));
|
||||
|
||||
if(empty($this->postParam("newContent")) && $attachmentsCount < 1)
|
||||
$this->returnJson(["error" => "Empty post"]);
|
||||
|
||||
$post->setEdited(time());
|
||||
$post->setContent($this->postParam("newContent"));
|
||||
|
||||
try {
|
||||
$post->setContent($this->postParam("newContent"));
|
||||
} catch(\LengthException $e) {
|
||||
$this->returnJson(["error" => $e->getMessage()]);
|
||||
}
|
||||
|
||||
if($this->postParam("type") === "post") {
|
||||
$post->setNsfw($this->postParam("nsfw") == "true");
|
||||
|
|
|
@ -358,6 +358,11 @@ $(document).on("click", "#editPost", (e) => {
|
|||
"&fromgroup="+(content.querySelector("#fromgroup") != null ? content.querySelector("#fromgroup").checked : 0))
|
||||
})
|
||||
|
||||
u(".editMenu").on("keydown", (e) => {
|
||||
if(e.ctrlKey && e.keyCode === 13)
|
||||
content.querySelector("#endEditing").click()
|
||||
});
|
||||
|
||||
text.style.display = "none"
|
||||
setupWallPostInputHandlers(999)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue