| Auth on view content
This commit is contained in:
parent
e4f3ddb6cd
commit
a9111959cd
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue