diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index f4a8e898..60497961 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -200,6 +200,7 @@ final class WallPresenter extends OpenVKPresenter 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 @@ -240,6 +241,7 @@ final class WallPresenter extends OpenVKPresenter foreach ($posts as $post) { $this->template->posts[] = $this->posts->get($post->id); } + $this->template->feedIgnoreButton = true; } public function renderHashtagFeed(string $hashtag): void diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index b39b8239..cb005144 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -58,6 +58,7 @@ {_pinned} + {if $canBePinned && !($forceNoPinLink ?? false) && $compact == false} {if $post->isPinned()} diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 3612aa1d..7c86382a 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -133,6 +133,10 @@ {if !($forceNoDeleteLink ?? false) && $canBeDeleted} {_delete}  |  + {/if} + + {if $feedIgnoreButton && !$canBeDeleted} + {_feed_ignore}  |  {/if} {if !($forceNoPinLink ?? false) && $canBePinned} diff --git a/Web/static/css/main.css b/Web/static/css/main.css index 0332d278..82fa41d7 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -914,6 +914,15 @@ h4 { } } +.post-hidden { + display: none; +} + +.ignore-message { + padding: 5px 0; +} + + .small-textarea { height: 24px; } diff --git a/Web/static/css/microblog.css b/Web/static/css/microblog.css index 503af42a..79272fac 100644 --- a/Web/static/css/microblog.css +++ b/Web/static/css/microblog.css @@ -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; diff --git a/Web/static/js/al_feed.js b/Web/static/js/al_feed.js index 66eeddf1..c35161bc 100644 --- a/Web/static/js/al_feed.js +++ b/Web/static/js/al_feed.js @@ -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(` +
+ ${tr(`feed_${ENTITY_NAME}_ignored`)} ${tr('feed_unignore')} +
+ `) + } + } +}) + u(document).on('click', '#__feed_settings_link', (e) => { e.preventDefault() diff --git a/locales/en.strings b/locales/en.strings index bca784ef..fd13f8da 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -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"; diff --git a/locales/ru.strings b/locales/ru.strings index f933d724..0a6080c6 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -290,6 +290,11 @@ "change_geo_name" = "Изменить название точки"; "change_geo_name_new" = "Новое название"; +"feed_user_ignored" = "Пользователь больше не будет появляться в ленте."; +"feed_club_ignored" = "Группа больше не будет появляться в ленте."; +"feed_unignore" = "Вернуть."; +"feed_ignore" = "Не интересно"; + /* Friends */ "friends" = "Друзья"; diff --git a/locales/uk.strings b/locales/uk.strings index c54b4769..6295cbee 100644 --- a/locales/uk.strings +++ b/locales/uk.strings @@ -280,6 +280,11 @@ "change_geo_name" = "Змінити назву розташування"; "change_geo_name_new" = "Нова назва"; +"feed_user_ignored" = "Користувач більше не з'являтиметься у стрічці."; +"feed_club_ignored" = "Спiльнота більше не з'являтиметься у стрічці."; +"feed_unignore" = "Повернути."; +"feed_ignore" = "Не цікаво"; + /* Friends */ "friends" = "Друзі";