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[]; + }; + }, +};