From a55410ec877c3946cb401616f0482de206d2c262 Mon Sep 17 00:00:00 2001 From: Andrey Romanov <64421792+quick6response@users.noreply.github.com> Date: Sun, 28 Apr 2024 00:13:43 +0300 Subject: [PATCH] task#213 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: Исправлена установка ответа галочки при шеринге через метод сообщений add: Добавлен сервис, который исправляет проблему типизации библиотеки https://github.com/VKCOM/vk-bridge/issues/554 --- src/modals/post/ModalSharePost.tsx | 12 +++++++++--- src/modals/users/UsersShareModalCard.tsx | 12 +++++++++--- src/services/vk/vk.bridge.service.ts | 9 +++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 src/services/vk/vk.bridge.service.ts diff --git a/src/modals/post/ModalSharePost.tsx b/src/modals/post/ModalSharePost.tsx index 0afb2dc..434742d 100644 --- a/src/modals/post/ModalSharePost.tsx +++ b/src/modals/post/ModalSharePost.tsx @@ -5,6 +5,7 @@ import { PostModel } from '@models/post.model'; import { ModalInterface } from '@routes/interface/modal.interface'; import { ApplicationService } from '@services/application/application.service'; import { photoService } from '@services/photo/photo.service'; +import { vkBridgeService } from '@services/vk/vk.bridge.service'; import { Icon24Done } from '@vkontakte/icons'; import bridge from '@vkontakte/vk-bridge'; import { Avatar, Button, ButtonGroup, ModalCard } from '@vkontakte/vkui'; @@ -28,11 +29,16 @@ export const ModalSharePost: FC = ({ onClose, nav }) => { const [isShareHistory, setIsShareHistory] = useState(false); const onClickShareMessage = () => { - bridge - .send('VKWebAppShare', { + vkBridgeService + .VKWebAppShare({ link: getUrlPost(hash), }) - .then(() => setIsShareMessage(true)); + .then((response) => { + if (response?.result.length > 0) { + // Запись отправлена в ЛС + setIsShareMessage(true); + } + }); }; const onClickPostShare = () => { diff --git a/src/modals/users/UsersShareModalCard.tsx b/src/modals/users/UsersShareModalCard.tsx index fc7289b..d6d215b 100644 --- a/src/modals/users/UsersShareModalCard.tsx +++ b/src/modals/users/UsersShareModalCard.tsx @@ -5,6 +5,7 @@ import { ModalInterface } from '@routes/interface/modal.interface'; import { ApplicationService } from '@services/application/application.service'; import { urlService } from '@services/link/url.service'; import { userService } from '@services/user/user.service'; +import { vkBridgeService } from '@services/vk/vk.bridge.service'; import { Icon24Done, Icon56ShareOutline } from '@vkontakte/icons'; import bridge from '@vkontakte/vk-bridge'; import { Button, ButtonGroup, Link, ModalCard } from '@vkontakte/vkui'; @@ -23,13 +24,18 @@ export const UsersShareModalCard: FC = ({ nav, onClose }) => { ); const onClickShareMessage = () => { - bridge - .send('VKWebAppShare', { + vkBridgeService + .VKWebAppShare({ link: `${ApplicationService.getURLApplicationByClient(client)}#profile/user?userId=${ isMyShareProfile ? userId : userIdParameters }`, }) - .then(() => setIsShareMessage(true)); + .then((response) => { + if (response?.result.length > 0) { + // Запись отправлена в ЛС + setIsShareMessage(true); + } + }); }; const onClickPostShare = () => { diff --git a/src/services/vk/vk.bridge.service.ts b/src/services/vk/vk.bridge.service.ts new file mode 100644 index 0000000..b93447a --- /dev/null +++ b/src/services/vk/vk.bridge.service.ts @@ -0,0 +1,9 @@ +import bridge, { LinkShareResult } from '@vkontakte/vk-bridge'; + +export const vkBridgeService = { + VKWebAppShare: async (parameters: { link: string }) => { + return (await bridge.send('VKWebAppShare', parameters)) as unknown as { + result: LinkShareResult[]; + }; + }, +};