From e4983df532e39258a9609b2babeb3fa9bdcde46e Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:42:03 +0300 Subject: [PATCH] feat(settings): move js settings from feed settigs --- VKAPI/Handlers/Photos.php | 39 +++++++++++------ Web/Presenters/templates/User/Settings.xml | 11 +++++ Web/static/js/al_feed.js | 51 ++++++++++++---------- locales/en.strings | 1 + locales/ru.strings | 1 + 5 files changed, 67 insertions(+), 36 deletions(-) diff --git a/VKAPI/Handlers/Photos.php b/VKAPI/Handlers/Photos.php index 9e529235..395862cf 100644 --- a/VKAPI/Handlers/Photos.php +++ b/VKAPI/Handlers/Photos.php @@ -278,19 +278,23 @@ final class Photos extends VKAPIRequestHandler $album = (new Albums())->getAlbumByOwnerAndId($owner_id, $album_id); - if (!$album || $album->isDeleted() || $album->isCreatedBySystem()) + if (!$album || $album->isDeleted() || $album->isCreatedBySystem()) { $this->fail(114, "Invalid album id"); - if (!$album->canBeModifiedBy($this->getUser())) + } + if (!$album->canBeModifiedBy($this->getUser())) { $this->fail(15, "Access denied"); + } - if (!is_null($title) && !empty($title) && !ctype_space($content)) + if (!is_null($title) && !empty($title) && !ctype_space($content)) { $album->setName($title); - if (!is_null($description)) + } + if (!is_null($description)) { $album->setDescription($description); + } try { $album->save(); - } catch(\Throwable $e) { + } catch (\Throwable $e) { return 1; } @@ -312,10 +316,12 @@ final class Photos extends VKAPIRequestHandler if (empty($album_ids)) { $owner = get_entity_by_id($owner_id); - if (!$owner || !$owner->canBeViewedBy($this->getUser())) + if (!$owner || !$owner->canBeViewedBy($this->getUser())) { $this->fail(15, "Access denied"); - if ($owner_id > 0 && !$owner->getPrivacyPermission('photos.read', $this->getUser())) + } + if ($owner_id > 0 && !$owner->getPrivacyPermission('photos.read', $this->getUser())) { $this->fail(15, "Access denied"); + } $albums_list = null; if ($owner_id > 0) { @@ -338,8 +344,9 @@ final class Photos extends VKAPIRequestHandler } foreach ($albums_list as $album) { - if (!$need_system && $album->isCreatedBySystem()) # TODO use queries + if (!$need_system && $album->isCreatedBySystem()) { # TODO use queries continue; + } $res["items"][] = $album->toVkApiStruct($this->getUser(), $need_covers, $photo_sizes); } @@ -355,7 +362,7 @@ final class Photos extends VKAPIRequestHandler $user_id = $this->getUser()->getId(); } - if (!is_null($user_id)){ + if (!is_null($user_id)) { $__user = (new UsersRepo())->get($user_id); if (!$__user || $__user->isDeleted() || !$__user->getPrivacyPermission('photos.read', $this->getUser())) { $this->fail(15, "Access denied"); @@ -388,8 +395,9 @@ final class Photos extends VKAPIRequestHandler foreach ($photos_splitted_list as $photo_id) { $photo_s_id = explode("_", $photo_id); $photo = (new PhotosRepo())->getByOwnerAndVID((int) $photo_s_id[0], (int) $photo_s_id[1]); - if(!$photo || $photo->isDeleted() || !$photo->canBeViewedBy($this->getUser())) + if (!$photo || $photo->isDeleted() || !$photo->canBeViewedBy($this->getUser())) { continue; + } $res[] = $photo->toVkApiStruct($photo_sizes, $extended); } @@ -435,8 +443,9 @@ final class Photos extends VKAPIRequestHandler $id = explode("_", $photo); $photo_entity = (new PhotosRepo())->getByOwnerAndVID((int) $id[0], (int) $id[1]); - if (!$photo_entity || $photo_entity->isDeleted() || !$photo_entity->canBeViewedBy($this->getUser())) + if (!$photo_entity || $photo_entity->isDeleted() || !$photo_entity->canBeViewedBy($this->getUser())) { continue; + } $res["items"][] = $photo_entity->toVkApiStruct($photo_sizes, $extended); } @@ -485,13 +494,14 @@ final class Photos extends VKAPIRequestHandler $this->requireUser(); $this->willExecuteWriteAction(); - if(!$owner_id) { + if (!$owner_id) { $owner_id = $this->getUser()->getId(); } if (is_null($photos)) { - if(is_null($photo_id)) + if (is_null($photo_id)) { return 0; + } $photo = (new PhotosRepo())->getByOwnerAndVID($owner_id, $photo_id); if (!$photo || $photo->isDeleted() || !$photo->canBeModifiedBy($this->getUser())) { @@ -508,8 +518,9 @@ final class Photos extends VKAPIRequestHandler foreach ($photos_list as $photo_id) { $id = explode("_", $photo_id); $photo = (new PhotosRepo())->getByOwnerAndVID((int) $id[0], (int) $id[1]); - if (!$photo || $photo->isDeleted() || !$photo->canBeModifiedBy($this->getUser())) + if (!$photo || $photo->isDeleted() || !$photo->canBeModifiedBy($this->getUser())) { continue; + } $photo->delete(); } diff --git a/Web/Presenters/templates/User/Settings.xml b/Web/Presenters/templates/User/Settings.xml index f4cf0271..306cd774 100644 --- a/Web/Presenters/templates/User/Settings.xml +++ b/Web/Presenters/templates/User/Settings.xml @@ -595,6 +595,17 @@ + + + + + + + + +
+ {_ui_settings_window} +

{_ui_settings_sidebar}

diff --git a/Web/static/js/al_feed.js b/Web/static/js/al_feed.js index 1153393b..66eeddf1 100644 --- a/Web/static/js/al_feed.js +++ b/Web/static/js/al_feed.js @@ -84,8 +84,6 @@ u(document).on('click', '#__feed_settings_link', (e) => { const CURRENT_PERPAGE = Number(__temp_url.searchParams.get('posts') ?? 10) const CURRENT_PAGE = Number(__temp_url.searchParams.get('p') ?? 1) const CURRENT_RETURN_BANNED = Number(__temp_url.searchParams.get('return_banned') ?? 0) - const CURRENT_AUTO_SCROLL = Number(localStorage.getItem('ux.auto_scroll') ?? 1) - const CURRENT_DISABLE_AJAX = Number(localStorage.getItem('ux.disable_ajax_routing') ?? 0) const COUNT = [1, 5, 10, 20, 30, 40, 50] u('#_feed_settings_container #__content').html(` @@ -116,26 +114,6 @@ u(document).on('click', '#__feed_settings_link', (e) => { - - - - - - - - @@ -299,3 +277,32 @@ u(document).on('change', `input[data-act='localstorage_item']`, (e) => { localStorage.setItem(e.target.name, Number(e.target.checked)) }) + +function openJsSettings() { + const CURRENT_AUTO_SCROLL = Number(localStorage.getItem('ux.auto_scroll') ?? 1) + const CURRENT_DISABLE_AJAX = Number(localStorage.getItem('ux.disable_ajax_routing') ?? 0) + + u("#_js_settings td").remove() + u("#_js_settings").append(` + + + + + + + + + `) +} diff --git a/locales/en.strings b/locales/en.strings index a4ab2411..eb2cd82b 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -703,6 +703,7 @@ "round_avatars" = "Round"; "apply_style_for_this_device" = "Apply style only for this device"; +"ui_settings_window" = "Advanced settings"; "search_for_groups" = "Search for groups"; "search_for_users" = "Search for users"; diff --git a/locales/ru.strings b/locales/ru.strings index 1315f82b..6122b9a7 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -676,6 +676,7 @@ "cut" = "Квадратные"; "round_avatars" = "Круглые"; "apply_style_for_this_device" = "Применить стиль только для этого устройства"; +"ui_settings_window" = "Дополнительные настройки"; "search_for_groups" = "Поиск групп"; "search_for_users" = "Поиск людей"; "search_for_posts" = "Поиск записей";
- - - - - -
- - - - - -
+ + + + + +
+ + + + + +