Skip to content

Commit

Permalink
task#213
Browse files Browse the repository at this point in the history
fix:
Исправлена установка ответа галочки при шеринге через метод сообщений

add:
Добавлен сервис, который исправляет проблему типизации библиотеки VKCOM/vk-bridge#554
  • Loading branch information
quick6response committed Apr 27, 2024
1 parent 3f54ba5 commit a55410e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/modals/post/ModalSharePost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -28,11 +29,16 @@ export const ModalSharePost: FC<ModalInterface> = ({ 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 = () => {
Expand Down
12 changes: 9 additions & 3 deletions src/modals/users/UsersShareModalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -23,13 +24,18 @@ export const UsersShareModalCard: FC<ModalInterface> = ({ 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 = () => {
Expand Down
9 changes: 9 additions & 0 deletions src/services/vk/vk.bridge.service.ts
Original file line number Diff line number Diff line change
@@ -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[];
};
},
};

0 comments on commit a55410e

Please sign in to comment.