8000 feat(FeedReports): Make Feed Great Again by xRy0 · Pull Request #1302 · OpenVK/openvk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(FeedReports): Make Feed Great Again #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Web/Presenters/WallPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public function renderFeed(): void
foreach ($posts->page((int) ($_GET["p"] ?? 1), $perPage) as $post) {
$this->template->posts[] = $this->posts->get($post->id);
}
$this->template->feedIgnoreButton = true;
}

public function renderGlobalFeed(): void
Expand Down Expand Up @@ -240,6 +241,7 @@ public function renderGlobalFeed(): void
foreach ($posts as $post) {
$this->template->posts[] = $this->posts->get($post->id);
}
$this->template->feedIgnoreButton = true;
}

public function renderHashtagFeed(string $hashtag): void
Expand Down
25 changes: 1 addition & 24 deletions Web/Presenters/templates/Wall/Post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,6 @@
>
{_changes_history}
</a>
<a n:if="$canReport ?? false" class="profile_link" style="display:block;width:96%;" href="javascript:reportPost()">{_report}</a>
<a n:if="$canReport ?? false" class="profile_link" style="display:block;width:96%;" href="javascript:reportPost({$post->getId()})">{_report}</a>
</div>
<script n:if="$canReport ?? false">
function reportPost() {
uReportMsgTxt = tr("going_to_report_post");
uReportMsgTxt += "<br/>"+tr("report_question_text");
uReportMsgTxt += "<br/><br/><b>"+tr("report_reason")+"</b>: <input type='text' id='uReportMsgInput' placeholder='" + tr("reason") + "' />"

MessageBox(tr("report_question"), uReportMsgTxt, [tr("confirm_m"), tr("cancel")], [
(function() {
res = document.querySelector("#uReportMsgInput").value;
xhr = new XMLHttpRequest();
xhr.open("GET", "/report/" + {$post->getId()} + "?reason=" + res + "&type=post", true);
xhr. {
if(xhr.responseText.indexOf("reason") === -1)
MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]);
else
MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]);
});
xhr.send(null);
}),
Function.noop
]);
}
</script>
{/block}
1 change: 1 addition & 0 deletions Web/Presenters/templates/components/post/microblogpost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<span n:if="$post->isPinned()" class="nobold">{_pinned}</span>

<a n:if="$canBeDeleted && !($forceNoDeleteLink ?? false) && $compact == false" class="delete" href="/wall{$post->getPrettyId()}/delete"></a>
<a n:if="$feedIgnoreButton && !$canBeDeleted" class="ignore" id="__ignoreSomeoneFeed" title="{_feed_ignore}" data-val='1' data-id="{$wallOwner->getRealId()}"></a>

{if $canBePinned && !($forceNoPinLink ?? false) && $compact == false}
{if $post->isPinned()}
Expand Down
10 changes: 9 additions & 1 deletion Web/Presenters/templates/components/post/oldpost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,16 @@

{if !($forceNoDeleteLink ?? false) && $canBeDeleted}
<a href="/wall{$post->getPrettyId()}/delete">{_delete}</a> &nbsp;|&nbsp;
{/if}

{if $feedIgnoreButton && !$canBeDeleted}
<a id="__ignoreSomeoneFeed" data-val='1' data-id="{$wallOwner->getRealId()}">{_feed_ignore}</a> &nbsp;|&nbsp;
{/if}


{if !$canBeDeleted}
<a href="javascript:reportPost({$post->getId()})">{_report}</a> &nbsp;|&nbsp;
{/if}

{if !($forceNoPinLink ?? false) && $canBePinned}
{if $post->isPinned()}
<a href="/wall{$post->getPrettyId()}/pin?act=unpin&hash={rawurlencode($csrfToken)}">{_unpin}</a>
Expand Down
9 changes: 9 additions & 0 deletions Web/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,15 @@ h4 {
}
}

.post-hidden {
display: none;
}

.ignore-message {
padding: 5px 0;
}


.small-textarea {
height: 24px;
}
Expand Down
23 changes: 23 additions & 0 deletions Web/static/css/microblog.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,29 @@
background-color: rgb(240, 240, 240);
}

.ignore {
float: right;
height: 16px;
width: 16px;
overflow: auto;
background: url("/assets/packages/static/openvk/img/ignore.png") no-repeat 0 0;
opacity: 0.1;
transition-duration: 0.3s;
}

.ignore:hover {
opacity: 0.4;
}

.post-hidden {
display: none;
}

.ignore-message {
padding: 5px 0;
border-bottom: 1px #ddd solid;
}

.post-author .delete {
float: right;
height: 16px;
Expand Down
Binary file added Web/static/img/ignore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions Web/static/js/al_feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,53 @@ u(document).on("click", "#__ignoreSomeone", async (e) => {
}
})

u(document).on("click", "#__ignoreSomeoneFeed", async (e) => {
e.preventDefault()

const TARGET = u(e.target)
const ENTITY_ID = Number(e.target.dataset.id)
const VAL = Number(e.target.dataset.val)
const ACT = VAL == 1 ? 'ignore' : 'unignore'
const METHOD_NAME = ACT == 'ignore' ? 'addBan' : 'deleteBan'
const PARAM_NAME = ENTITY_ID < 0 ? 'group_ids' : 'user_ids'
const ENTITY_NAME = ENTITY_ID < 0 ? 'club' : 'user'
const URL = `/method/newsfeed.${METHOD_NAME}?auth_mechanism=roaming&${PARAM_NAME}=${Math.abs(ENTITY_ID)}`

TARGET.closest('.post').addClass('lagged')
const REQ = await fetch(URL)
const RES = await REQ.json()
TARGET.closest('.post').removeClass('lagged')

if(RES.error_code) {
switch(RES.error_code) {
case -10:
fastError(';/')
break
case -50:
fastError(tr('ignored_sources_limit'))
break
default:
fastError(res.error_msg)
break
}
return
}

if(RES.response == 1) {
if(ACT == 'unignore') {
TARGET.closest('.scroll_node').find('.post').removeClass('post-hidden');
TARGET.closest('.ignore-message').remove()
} else {
TARGET.closest('.post').addClass('post-hidden');
TARGET.closest('.scroll_node').append(`
<div class="ignore-message" width="100%">
${tr(`feed_${ENTITY_NAME}_ignored`)} <a id="__ignoreSomeoneFeed" data-val='0' data-id='${ENTITY_ID}' href="#">${tr('feed_unignore')}</a>
</div>
`)
}
}
})

u(document).on('click', '#__feed_settings_link', (e) => {
e.preventDefault()

Expand Down Expand Up @@ -306,3 +353,26 @@ function openJsSettings() {
</tr>
`)
}


function reportPost(postId) {
uReportMsgTxt = tr("going_to_report_post");
uReportMsgTxt += "<br/>"+tr("report_question_text");
uReportMsgTxt += "<br/><br/><b>"+tr("report_reason")+"</b>: <input type='text' id='uReportMsgInput' placeholder='" + tr("reason") + "' />"

MessageBox(tr("report_question"), uReportMsgTxt, [tr("confirm_m"), tr("cancel")], [
(function() {
res = document.querySelector("#uReportMsgInput").value;
xhr = new XMLHttpRequest();
xhr.open("GET", "/report/" + postId + "?reason=" + res + "&type=post", true);
xhr. {
if(xhr.responseText.indexOf("reason") === -1)
MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]);
else
MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]);
});
xhr.send(null);
}),
Function.noop
]);
}
5 changes: 5 additions & 0 deletions locales/en.strings
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@
"subscriptions_one" = "$1 subscription";
"subscriptions_other" = "$1 subscriptions";

"feed_user_ignored" = "User will no longer appear in the feed.";
"feed_club_ignored" = "Club will no longer appear in the feed.";
"feed_unignore" = "Restore.";
"feed_ignore" = "Not interested";

/* Group */

"group" = "Group";
Expand Down
5 changes: 5 additions & 0 deletions locales/ru.strings
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@
"change_geo_name" = "Изменить название точки";
"change_geo_name_new" = "Новое название";

"feed_user_ignored" = "Пользователь больше не будет появляться в ленте.";
"feed_club_ignored" = "Группа больше не будет появляться в ленте.";
"feed_unignore" = "Вернуть.";
"feed_ignore" = "Не интересно";

/* Friends */

"friends" = "Друзья";
Expand Down
5 changes: 5 additions & 0 deletions locales/uk.strings
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@
"change_geo_name" = "Змінити назву розташування";
"change_geo_name_new" = "Нова назва";

"feed_user_ignored" = "Користувач більше не з'являтиметься у стрічці.";
"feed_club_ignored" = "Спiльнота більше не з'являтиметься у стрічці.";
"feed_unignore" = "Повернути.";
"feed_ignore" = "Не цікаво";

/* Friends */

"friends" = "Друзі";
Expand Down
0