diff --git a/src/components/bitcoinConnect/CoursePaymentButton.js b/src/components/bitcoinConnect/CoursePaymentButton.js
index 463c3e4..d614881 100644
--- a/src/components/bitcoinConnect/CoursePaymentButton.js
+++ b/src/components/bitcoinConnect/CoursePaymentButton.js
@@ -6,6 +6,7 @@ import { initializeBitcoinConnect } from './BitcoinConnect';
import { LightningAddress } from '@getalby/lightning-tools';
import { useToast } from '@/hooks/useToast';
import { useSession } from 'next-auth/react';
+import { useRouter } from 'next/router';
import GenericButton from '@/components/buttons/GenericButton';
import axios from 'axios'; // Import axios for API calls
@@ -20,19 +21,20 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
const [invoice, setInvoice] = useState(null);
const [userId, setUserId] = useState(null);
const { showToast } = useToast();
- const { data: session } = useSession();
+ const { data: session, status } = useSession();
const [dialogVisible, setDialogVisible] = useState(false); // New state for dialog visibility
-
- useEffect(() => {
- if (session?.user) {
- setUserId(session.user.id);
- }
- }, [session]);
+ const router = useRouter();
useEffect(() => {
initializeBitcoinConnect();
}, []);
+ useEffect(() => {
+ if (session && session.user) {
+ setUserId(session.user.id);
+ }
+ }, [status, session]);
+
useEffect(() => {
const fetchInvoice = async () => {
try {
@@ -78,17 +80,24 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
return (
<>
- setDialogVisible(true)}
+ {
+ if (status === 'unauthenticated') {
+ console.log('unauthenticated');
+ router.push('/auth/signin');
+ } else {
+ setDialogVisible(true);
+ }
+ }}
disabled={!invoice}
severity='primary'
rounded
icon='pi pi-wallet'
className='text-[#f8f8ff] text-sm'
/>
-
router.push(`/details/${processedEvent.id}/edit`)} label="Edit" severity='warning' outlined />
- window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip="View Nostr Event" tooltipOptions={{ position: 'right' }} />
+ window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={ isMobileView ? null : "View Nostr Event" } tooltipOptions={{ position: paidCourse ? 'left' : 'right' }} />
) : (
- window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip="View Nostr Event" tooltipOptions={{ position: paidCourse ? 'left' : 'right' }} />
+ window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={ isMobileView ? null : "View Nostr Event" } tooltipOptions={{ position: paidCourse ? 'left' : 'right' }} />
)}
diff --git a/src/components/content/courses/DocumentLesson.js b/src/components/content/courses/DocumentLesson.js
index c001a9e..4c5b3bd 100644
--- a/src/components/content/courses/DocumentLesson.js
+++ b/src/components/content/courses/DocumentLesson.js
@@ -9,6 +9,7 @@ import { nip19 } from "nostr-tools";
import { Divider } from "primereact/divider";
import { getTotalFromZaps } from "@/utils/lightning";
import dynamic from "next/dynamic";
+import useWindowWidth from "@/hooks/useWindowWidth";
import { defaultRelayUrls } from "@/context/NDKContext";
const MDDisplay = dynamic(
@@ -23,6 +24,8 @@ const DocumentLesson = ({ lesson, course, decryptionPerformed, isPaid }) => {
const [nAddress, setNAddress] = useState(null);
const { zaps, zapsLoading, zapsError } = useZapsQuery({ event: lesson, type: "lesson" });
const { returnImageProxy } = useImageProxy();
+ const windowWidth = useWindowWidth();
+ const isMobileView = windowWidth <= 768;
useEffect(() => {
if (!zaps || zapsLoading || zapsError) return;
@@ -119,7 +122,7 @@ const DocumentLesson = ({ lesson, course, decryptionPerformed, isPaid }) => {
['t', topic]),
['published_at', Math.floor(Date.now() / 1000).toString()],
...(draft?.price ? [['price', draft.price.toString()], ['location', `https://plebdevs.com/details/${draft.id}`]] : []),
- ...(draft?.additionalLinks ? draft.additionalLinks.map(link => ['r', link]) : []),
+ ...(draft?.additionalLinks ? draft.additionalLinks.filter(link => link !== 'https://plebdevs.com').map(link => ['r', link]) : []),
];
type = 'document';
@@ -293,7 +293,7 @@ export default function DraftCourseDetails({ processedEvent, draftId, lessons })
...draft.topics.map(topic => ['t', topic]),
['published_at', Math.floor(Date.now() / 1000).toString()],
...(draft?.price ? [['price', draft.price.toString()], ['location', `https://plebdevs.com/details/${draft.id}`]] : []),
- ...(draft?.additionalLinks ? draft.additionalLinks.map(link => ['r', link]) : []),
+ ...(draft?.additionalLinks ? draft.additionalLinks.filter(link => link !== 'https://plebdevs.com').map(link => ['r', link]) : []),
];
type = 'video';
diff --git a/src/components/content/courses/VideoLesson.js b/src/components/content/courses/VideoLesson.js
index 947e3ca..b0cc42c 100644
--- a/src/components/content/courses/VideoLesson.js
+++ b/src/components/content/courses/VideoLesson.js
@@ -10,6 +10,7 @@ import { getTotalFromZaps } from "@/utils/lightning";
import dynamic from "next/dynamic";
import { Divider } from "primereact/divider";
import { defaultRelayUrls } from "@/context/NDKContext";
+import useWindowWidth from "@/hooks/useWindowWidth";
const MDDisplay = dynamic(
() => import("@uiw/react-markdown-preview"),
@@ -23,6 +24,8 @@ const VideoLesson = ({ lesson, course, decryptionPerformed, isPaid }) => {
const [nAddress, setNAddress] = useState(null);
const { zaps, zapsLoading, zapsError } = useZapsQuery({ event: lesson, type: "lesson" });
const { returnImageProxy } = useImageProxy();
+ const windowWidth = useWindowWidth();
+ const isMobileView = windowWidth <= 768;
useEffect(() => {
if (!zaps || zapsLoading || zapsError) return;
@@ -130,7 +133,7 @@ const VideoLesson = ({ lesson, course, decryptionPerformed, isPaid }) => {
{
if (zaps.length > 0) {
@@ -172,7 +173,7 @@ const DocumentDetails = ({ processedEvent, topics, title, summary, image, price,
router.push(`/details/${nAddress}/edit`)} label="Edit" severity='warning' outlined />
{
if (zaps.length > 0) {
@@ -165,11 +166,11 @@ const VideoDetails = ({ processedEvent, topics, title, summary, image, price, au
router.push(`/details/${nAddress}/edit`)} label="Edit" severity='warning' outlined />
- window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip="View Nostr Event" tooltipOptions={{ position: 'right' }} />
+ window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={ isMobileView ? null : "View Nostr Event" } tooltipOptions={{ position: 'right' }} />
) : (
- window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip="View Nostr Event" tooltipOptions={{ position: paidResource ? 'left' : 'right' }} />
+ window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={ isMobileView ? null : "View Nostr Event" } tooltipOptions={{ position: paidResource ? 'left' : 'right' }} />
)}
diff --git a/src/components/feeds/messages/CommunityMessage.js b/src/components/feeds/messages/CommunityMessage.js
index 169c669..284b7dc 100644
--- a/src/components/feeds/messages/CommunityMessage.js
+++ b/src/components/feeds/messages/CommunityMessage.js
@@ -10,6 +10,7 @@ import NostrIcon from '../../../../public/images/nostr.png';
import Image from 'next/image';
import { nip19 } from 'nostr-tools';
import ZapThreadsWrapper from '@/components/ZapThreadsWrapper';
+import useWindowWidth from '@/hooks/useWindowWidth';
const StackerNewsIconComponent = () => (