| Auth on view content

This commit is contained in:
rakhimovkamran committed 2024-10-27 17:57:03 +05:00
1 parent e4f3ddb6cd
commit a9111959cd
2 files changed
+10 -1

No files matched your search

+7 -1
View File
@@ -7,6 +7,7 @@ import { usePurchaseContent, useViewContent } from "~/shared/services/content";
import { fromNanoTON } from "~/shared/utils";
import {useCallback, useEffect, useMemo} from "react";
import { AudioPlayer } from "~/shared/ui/audio-player";
import {useAuth} from "~/shared/services/auth";
export const ViewContentPage = () => {
const WebApp = useWebApp();
@@ -17,13 +18,18 @@ export const ViewContentPage = () => {
const [tonConnectUI] = useTonConnectUI();
const auth = useAuth();
const handleBuyContent = useCallback(async () => {
try {
if (!tonConnectUI.connected) {
await tonConnectUI.openModal();
return;
await auth.mutateAsync();
}
await auth.mutateAsync();
const contentResponse = await purchaseContent({
content_address: content?.data?.encrypted?.cid,
license_type: "resale",
+3
View File
@@ -84,6 +84,9 @@ export const useAuth = () => {
console.error("Error in authentication request: ", error);
throw new Error("Failed to authenticate.");
});
} else {
void tonConnectUI.disconnect();
localStorage.removeItem(sessionStorageKey)
}
});
};