Теперь уведомление о принятии поста не приходит, если вы приняли свой же пост

Пофикшен баг перехода в предложку

Добавлен старый вид постов в предложке

Теперь счётчик постов в предложке у прикреплённой группы обновляется при принятии или отклонении поста

Убрано всплывающее уведомление об отклонении поста (оно раздражает)

Теперь если вы посмотрели все посты на одной странице (не на первой) и на ней не осталось постов, вас телепортирует на предыдущую страницу
This commit is contained in:
lalka2016 2023-08-10 11:28:48 +03:00
parent e9a0b5ab19
commit f1fdb15bb9
7 changed files with 65 additions and 14 deletions

View file

@ -155,7 +155,8 @@ class Wall implements Handler
$post->save();
(new PostAcceptedNotification($author, $post, $post->getWallOwner()))->emit();
if($author->getId() != $this->user->getId())
(new PostAcceptedNotification($author, $post, $post->getWallOwner()))->emit();
$resolve(["id" => $post->getPrettyId(), "new_count" => $this->posts->getSuggestedPostsCount($post->getWallOwner()->getId())]);
}

View file

@ -472,7 +472,9 @@ final class Wall extends VKAPIRequestHandler
$post->setContent($message);
$post->save();
(new PostAcceptedNotification($author, $post, $post->getWallOwner()))->emit();
if($author->getId() != $this->getUser()->getId())
(new PostAcceptedNotification($author, $post, $post->getWallOwner()))->emit();
return (object)["post_id" => $post->getVirtualId()];
}

View file

@ -219,7 +219,7 @@
{$club->getName()}
<object type="internal/link" style="white-space: normal;" id="sug{$club->getId()}" n:if="$club->getSuggestedPostsCount() > 0 && $club->getWallType() == 2">
<a href="{$club->getURL()}/suggested">
<a href="/club{$club->getId()}/suggested">
(<b>{$club->getSuggestedPostsCount()}</b>)
</a>
</object>

View file

@ -13,8 +13,13 @@
{else}
<h4 id="cound">{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}</h4>
<div id="postz">
{var $microblog = $thisUser->hasMicroblogEnabled()}
{foreach $posts as $post}
{include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true}
{if $microblog}
{include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
{else}
{include "../components/post/oldpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
{/if}
{/foreach}
{include "../components/paginator.xml", conf => (object) [

View file

@ -1,5 +1,5 @@
{var $club = $notification->getModel(1)}
{_nt_in_club}
<a href="{$club->getURL()}/suggested"><b>{$club->getName()}</b></a>
<a href="/club{$club->getId()}/suggested"><b>{$club->getName()}</b></a>
{_nt_new_suggested_posts}

View file

@ -50,7 +50,7 @@
</a>
{/if}
<br/>
<a href="/wall{$post->getPrettyId()}" class="date">
<a href="{if !$suggestion}/wall{$post->getPrettyId()}{else}javascript:void(0){/if}" class="date">
{$post->getPublicationTime()}{if $post->isPinned()}, {_pinned}{/if}
<a n:if="!empty($platform)" class="client_app" data-app-tag="{$platform}" data-app-name="{$platformDetails['name']}" data-app-url="{$platformDetails['url']}" data-app-img="{$platformDetails['img']}">
<img src="/assets/packages/static/openvk/img/app_icons_mini/{$post->getPlatform(this)}.svg">
@ -59,7 +59,7 @@
</div>
<div class="post-content" id="{$post->getPrettyId()}">
<div class="text" id="text{$post->getPrettyId()}">
{$post->getText()|noescape}
<span class="really_text">{$post->getText()|noescape}</span>
<div n:ifcontent class="attachments_b">
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
@ -67,6 +67,10 @@
</div>
</div>
</div>
<div n:if="$suggestion && $post->canBePinnedBy($thisUser ?? NULL)" class="suggestionControls" style="margin-bottom: 7px;">
<input type="button" class="button" id="publish_post" data-id="{$post->getId()}" value="{_publish_suggested}">
<input type="button" class="button" id="decline_post" data-id="{$post->getId()}" value="{_decline_suggested}">
</div>
<div n:if="$post->isAd()" style="color:grey;">
<br/>
&nbsp;! Этот пост был размещён за взятку.

View file

@ -308,9 +308,22 @@ $(document).on("click", "#publish_post", async (e) => {
NewNotification(tr("suggestion_succefully_published"), tr("suggestion_press_to_go"), null, () => {window.location.assign("/wall" + post.id)});
document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post.new_count)
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
if(document.querySelector("object a[href='"+location.pathname+"'] b") != null) {
document.querySelector("object a[href='"+location.pathname+"'] b").innerHTML = post.new_count
if(post.new_count < 1) {
u("object a[href='"+location.pathname+"']").remove()
}
}
if(e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.tagName == "TABLE") {
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
} else {
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
}
if(document.querySelectorAll(".post.post-divider").length < 1 && post.new_count > 0) {
if(document.querySelectorAll(".post").length < 1 && post.new_count > 0) {
loadMoreSuggestedPosts()
}
}), Function.noop]);
@ -351,15 +364,27 @@ $(document).on("click", "#decline_post", async (e) => {
e.currentTarget.setAttribute("id", "decline_post")
e.currentTarget.classList.remove("loaded")
return 0;
} finally {
u("#deleteMe").remove()
}
NewNotification(tr("suggestion_succefully_declined"), "", null);
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
//NewNotification(tr("suggestion_succefully_declined"), "", null);
if(e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.tagName == "TABLE") {
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
} else {
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
}
document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post)
if(document.querySelectorAll(".post.post-divider").length < 1 && post > 0) {
if(document.querySelector("object a[href='"+location.pathname+"'] b") != null) {
document.querySelector("object a[href='"+location.pathname+"'] b").innerHTML = post
if(post < 1) {
u("object a[href='"+location.pathname+"']").remove()
}
}
if(document.querySelectorAll(".post").length < 1 && post > 0) {
loadMoreSuggestedPosts()
}
})
@ -377,6 +402,20 @@ function loadMoreSuggestedPosts()
let parser = new DOMParser()
let body = parser.parseFromString(xhr.responseText, "text/html").getElementById("postz")
if(body.querySelectorAll(".post").length < 1) {
let url = new URL(location.href)
url.searchParams.set("p", url.searchParams.get("p") - 1)
if(url.searchParams.get("p") < 1) {
return 0;
}
// OVK AJAX ROUTING ??????????
history.pushState({}, "", url)
loadMoreSuggestedPosts()
}
document.getElementById("postz").innerHTML = body.innerHTML
}