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

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

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

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

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

Теперь если вы посмотрели все посты на одной странице (не на первой) и на ней не осталось постов, вас телепортирует на предыдущую страницу
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,6 +155,7 @@ class Wall implements Handler
$post->save(); $post->save();
if($author->getId() != $this->user->getId())
(new PostAcceptedNotification($author, $post, $post->getWallOwner()))->emit(); (new PostAcceptedNotification($author, $post, $post->getWallOwner()))->emit();
$resolve(["id" => $post->getPrettyId(), "new_count" => $this->posts->getSuggestedPostsCount($post->getWallOwner()->getId())]); $resolve(["id" => $post->getPrettyId(), "new_count" => $this->posts->getSuggestedPostsCount($post->getWallOwner()->getId())]);

View file

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

View file

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

View file

@ -13,8 +13,13 @@
{else} {else}
<h4 id="cound">{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}</h4> <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"> <div id="postz">
{var $microblog = $thisUser->hasMicroblogEnabled()}
{foreach $posts as $post} {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} {/foreach}
{include "../components/paginator.xml", conf => (object) [ {include "../components/paginator.xml", conf => (object) [

View file

@ -1,5 +1,5 @@
{var $club = $notification->getModel(1)} {var $club = $notification->getModel(1)}
{_nt_in_club} {_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} {_nt_new_suggested_posts}

View file

@ -50,7 +50,7 @@
</a> </a>
{/if} {/if}
<br/> <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} {$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']}"> <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"> <img src="/assets/packages/static/openvk/img/app_icons_mini/{$post->getPlatform(this)}.svg">
@ -59,7 +59,7 @@
</div> </div>
<div class="post-content" id="{$post->getPrettyId()}"> <div class="post-content" id="{$post->getPrettyId()}">
<div class="text" id="text{$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 n:ifcontent class="attachments_b">
<div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}"> <div class="attachment" n:foreach="$post->getChildren() as $attachment" data-localized-nsfw-text="{_nsfw_warning}">
@ -67,6 +67,10 @@
</div> </div>
</div> </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;"> <div n:if="$post->isAd()" style="color:grey;">
<br/> <br/>
&nbsp;! Этот пост был размещён за взятку. &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)}); 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) document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post.new_count)
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
if(document.querySelectorAll(".post.post-divider").length < 1 && post.new_count > 0) { 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").length < 1 && post.new_count > 0) {
loadMoreSuggestedPosts() loadMoreSuggestedPosts()
} }
}), Function.noop]); }), Function.noop]);
@ -351,15 +364,27 @@ $(document).on("click", "#decline_post", async (e) => {
e.currentTarget.setAttribute("id", "decline_post") e.currentTarget.setAttribute("id", "decline_post")
e.currentTarget.classList.remove("loaded") e.currentTarget.classList.remove("loaded")
return 0; return 0;
} finally {
u("#deleteMe").remove()
} }
NewNotification(tr("suggestion_succefully_declined"), "", null); //NewNotification(tr("suggestion_succefully_declined"), "", null);
if(e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.tagName == "TABLE") {
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = "" 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) 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() loadMoreSuggestedPosts()
} }
}) })
@ -377,6 +402,20 @@ function loadMoreSuggestedPosts()
let parser = new DOMParser() let parser = new DOMParser()
let body = parser.parseFromString(xhr.responseText, "text/html").getElementById("postz") 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 document.getElementById("postz").innerHTML = body.innerHTML
} }