diff --git a/src/components/AppShowcase.tsx b/src/components/AppShowcase.tsx
new file mode 100644
index 00000000..11c643f6
--- /dev/null
+++ b/src/components/AppShowcase.tsx
@@ -0,0 +1,240 @@
+import React, { useState, useMemo } from "react";
+import { Search } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { useCurrentUser } from "@/hooks/useCurrentUser";
+import { useAppSubmissions } from "@/hooks/useAppSubmissions";
+import { AppShowcaseCard } from "@/components/AppShowcaseCard";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "@/components/ui/collapsible";
+import { nip19 } from 'nostr-tools';
+import { shuffleArray } from "@/lib/utils";
+import type { AppSubmission } from "@/hooks/useAppSubmissions";
+import { Skeleton } from "@/components/ui/skeleton";
+import { Card, CardContent } from "@/components/ui/card";
+import { RelaySelector } from "@/components/RelaySelector";
+
+export function AppShowcase() {
+ const { user } = useCurrentUser();
+ const { data: submissions = [], isLoading } = useAppSubmissions();
+ const [showAllApps, setShowAllApps] = useState(false);
+
+ const MODERATOR_NPUB = 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc';
+ const MODERATOR_HEX = (() => {
+ try {
+ const decoded = nip19.decode(MODERATOR_NPUB);
+ return decoded.type === 'npub' ? decoded.data : '';
+ } catch {
+ return '';
+ }
+ })();
+ const isModerator = user?.pubkey === MODERATOR_HEX;
+
+ // Filter submissions
+ const visibleSubmissions = submissions.filter(app => !app.isHidden);
+
+ // Separate template apps from other apps
+ const templateApps = useMemo(() =>
+ shuffleArray(visibleSubmissions.filter(app => app.appTags.includes('Template'))),
+ [visibleSubmissions]
+ );
+ const nonTemplateSubmissions = visibleSubmissions.filter(app => !app.appTags.includes('Template'));
+
+ // Get Halloween Hackathon 2025 apps that are featured (for main showcase)
+ const halloweenApps = useMemo(() =>
+ shuffleArray(nonTemplateSubmissions.filter(app =>
+ app.appTags.includes('Halloween Hackathon 2025') && app.isFeatured
+ )),
+ [nonTemplateSubmissions]
+ );
+
+ // Filter out Halloween Hackathon 2025 apps from other sections (unless featured, they go in Halloween section)
+ const nonHalloweenSubmissions = nonTemplateSubmissions.filter(app =>
+ !app.appTags.includes('Halloween Hackathon 2025')
+ );
+
+ // Shuffle featured and approved apps on each component mount/render for random display order
+ const featuredApps = useMemo(() =>
+ shuffleArray(nonHalloweenSubmissions.filter(app => app.isFeatured)),
+ [nonHalloweenSubmissions]
+ );
+ const approvedApps = useMemo(() =>
+ shuffleArray(nonHalloweenSubmissions.filter(app => app.isApproved && !app.isFeatured)),
+ [nonHalloweenSubmissions]
+ );
+
+ // Don't show showcase if no apps exist
+ if (isLoading) {
+ return (
+
+
+ {Array.from({ length: 6 }).map((_, i) => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))}
+
+
+ );
+ }
+
+ if (!submissions.length) {
+ return (
+
+
+
+
+
+ No apps found. Try another relay?
+
+
+
+
+
+
+ );
+ }
+
+ return (
+
+ {/* Apps Grid */}
+
+ {/* Featured Apps */}
+ {featuredApps.length > 0 && (
+
+
+
+ ⭐
+
+
+
Featured Apps
+
Handpicked applications showcasing the best of our community
+
+
+
+ {featuredApps.slice(0, 6).map((app) => (
+
+ ))}
+
+
+ )}
+
+ {/* Halloween Hackathon 2025 Apps */}
+ {halloweenApps.length > 0 && (
+
+
+
+ 🎃
+
+
+
Halloween Hackathon 2025
+
Featured spooky creations from our Halloween hackathon
+
+
+
+ {halloweenApps.slice(0, 6).map((app) => (
+
+ ))}
+
+
+ )}
+
+ {/* Templates Section */}
+ {templateApps.length > 0 && (
+
+
+
+ 📋
+
+
+
Templates
+
Ready-to-use templates to kickstart your project
+
+
+
+ {templateApps.slice(0, 6).map((app) => (
+
+ ))}
+
+
+ )}
+
+ {/* More Apps (Approved) - Collapsible */}
+ {approvedApps.length > 0 && (
+
+
+
+
+
+
+
+ {approvedApps.map((app) => (
+
+ ))}
+
+
+
+
+ )}
+
+
+ );
+}
\ No newline at end of file
diff --git a/src/components/AppShowcaseCard.tsx b/src/components/AppShowcaseCard.tsx
new file mode 100644
index 00000000..b979e784
--- /dev/null
+++ b/src/components/AppShowcaseCard.tsx
@@ -0,0 +1,589 @@
+import React, { useState } from 'react';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent } from '@/components/ui/card';
+import {
+ ExternalLink,
+ Edit,
+ Star,
+ StarOff,
+ Eye,
+ EyeOff,
+ MoreVertical,
+ CheckCircle,
+ XCircle,
+ User,
+ Home,
+ Contact
+} from 'lucide-react';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import type { AppSubmission } from '@/hooks/useAppSubmissions';
+import { useCurrentUser } from '@/hooks/useCurrentUser';
+import { useNostrPublish } from '@/hooks/useNostrPublish';
+import { useNostr } from '@nostrify/react';
+import { useAuthor } from '@/hooks/useAuthor';
+import { nip19 } from 'nostr-tools';
+import { useToast } from '@/hooks/useToast';
+import { useQueryClient } from '@tanstack/react-query';
+
+interface AppShowcaseCardProps {
+ app: AppSubmission;
+ onEdit?: (app: AppSubmission) => void;
+ showModerationControls?: boolean;
+ hideApprovalStatus?: boolean; // Hide pending/approval badges
+}
+
+export function AppShowcaseCard({ app, onEdit, showModerationControls, hideApprovalStatus }: AppShowcaseCardProps) {
+ const { user } = useCurrentUser();
+ const { nostr } = useNostr();
+ const { mutate: publishEvent, isPending } = useNostrPublish();
+ const queryClient = useQueryClient();
+ const [imageError, setImageError] = useState(false);
+ const { toast } = useToast();
+
+ // Get author pubkey from authorNpub field
+ const authorPubkey = React.useMemo(() => {
+ if (!app.authorNpub) return app.pubkey; // Fallback to event pubkey
+
+ try {
+ // If it's already a hex key, use it directly
+ if (app.authorNpub.length === 64 && /^[0-9a-f]+$/i.test(app.authorNpub)) {
+ return app.authorNpub;
+ }
+
+ // Otherwise try to decode as npub
+ const decoded = nip19.decode(app.authorNpub);
+ return decoded.type === 'npub' ? decoded.data : app.pubkey;
+ } catch {
+ return app.pubkey; // Fallback to event pubkey if decode fails
+ }
+ }, [app.authorNpub, app.pubkey]);
+
+ const { data: authorData } = useAuthor(authorPubkey);
+ const isOwner = user?.pubkey === app.pubkey;
+ const MODERATOR_NPUB = 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc';
+ const MODERATOR_HEX = (() => {
+ try {
+ const decoded = nip19.decode(MODERATOR_NPUB);
+ return decoded.type === 'npub' ? decoded.data : '';
+ } catch {
+ return '';
+ }
+ })();
+ const isModerator = user?.pubkey === MODERATOR_HEX;
+
+ // Check if this is a Halloween submission by looking for Halloween tags
+ const isHalloweenSubmission = app.appTags.includes('Halloween Hackathon 2025');
+
+ // Get contact info from Halloween submissions (these have lightning/email tags)
+ const getContactInfo = () => {
+ if (!isHalloweenSubmission) return null;
+
+ // Look for lightning and email tags in the event tags
+ const lightningTag = app.tags?.find((tag: string[]) => tag[0] === 'lightning')?.[1];
+ const emailTag = app.tags?.find((tag: string[]) => tag[0] === 'email')?.[1];
+
+ return { lightning: lightningTag, email: emailTag };
+ };
+
+ const handleCopyContactInfo = () => {
+ const contactInfo = getContactInfo();
+ if (!contactInfo) return;
+
+ const info: string[] = [];
+ if (contactInfo.lightning) info.push(`Lightning: ${contactInfo.lightning}`);
+ if (contactInfo.email) info.push(`Email: ${contactInfo.email}`);
+
+ const textToCopy = info.join('\n');
+ navigator.clipboard.writeText(textToCopy);
+
+ toast({
+ title: 'Contact Info Copied!',
+ description: `Copied ${info.length} contact method(s) to clipboard`
+ });
+ };
+
+ const handleModerationAction = async (action: 'feature' | 'unfeature' | 'approve' | 'unapprove' | 'hide' | 'unhide' | 'homepage' | 'unhomepage') => {
+ if (!isModerator || !user) return;
+
+ const dTag = app.tags.find(tag => tag[0] === 'd')?.[1];
+ if (!dTag) {
+ toast({
+ title: 'Error',
+ description: 'Cannot perform moderation action: missing app identifier',
+ variant: 'destructive'
+ });
+ return;
+ }
+
+ const appCoordinate = `${app.kind}:${app.pubkey}:${dTag}`;
+
+ try {
+ if (action === 'homepage' || action === 'unhomepage') {
+ // Get current homepage apps list
+ const currentHomepageLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-homepage-apps'],
+ limit: 1
+ }]);
+
+ const currentHomepageList = currentHomepageLists.reduce((latest: any, current: any) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null
+ );
+
+ // Get current homepage app coordinates
+ const currentHomepageApps = new Set();
+ if (currentHomepageList) {
+ currentHomepageList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => currentHomepageApps.add(tag[1]));
+ }
+
+ // Update the homepage set
+ if (action === 'homepage') {
+ currentHomepageApps.add(appCoordinate);
+ } else {
+ currentHomepageApps.delete(appCoordinate);
+ }
+
+ // Publish updated homepage apps list
+ publishEvent({
+ kind: 30267,
+ content: 'Soapbox homepage apps curated by moderators',
+ tags: [
+ ['d', 'soapbox-homepage-apps'],
+ ['title', 'Soapbox Homepage Apps'],
+ ['description', 'Apps displayed on the Soapbox homepage'],
+ ...Array.from(currentHomepageApps).map(coord => ['a', coord])
+ ],
+ created_at: Math.floor(Date.now() / 1000)
+ });
+
+ // If adding to homepage, also ensure it's approved
+ if (action === 'homepage') {
+ // Get current approved apps list
+ const currentApprovedLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-approved-apps'],
+ limit: 1
+ }]);
+
+ const currentApprovedList = currentApprovedLists.reduce((latest: any, current: any) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null
+ );
+
+ // Get current approved app coordinates
+ const currentApprovedApps = new Set();
+ if (currentApprovedList) {
+ currentApprovedList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => currentApprovedApps.add(tag[1]));
+ }
+
+ // Add to approved list if not already there
+ currentApprovedApps.add(appCoordinate);
+
+ // Publish updated approved apps list
+ publishEvent({
+ kind: 30267,
+ content: 'Soapbox approved apps curated by moderators',
+ tags: [
+ ['d', 'soapbox-approved-apps'],
+ ['title', 'Soapbox Approved Apps'],
+ ['description', 'Apps approved for the Soapbox showcase'],
+ ...Array.from(currentApprovedApps).map(coord => ['a', coord])
+ ],
+ created_at: Math.floor(Date.now() / 1000)
+ });
+ }
+
+ } else if (action === 'feature' || action === 'unfeature') {
+ // Get current featured apps list
+ const currentFeaturedLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-featured-apps'],
+ limit: 1
+ }]);
+
+ const currentFeaturedList = currentFeaturedLists.reduce((latest: any, current: any) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null
+ );
+
+ // Get current featured app coordinates
+ const currentFeaturedApps = new Set();
+ if (currentFeaturedList) {
+ currentFeaturedList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => currentFeaturedApps.add(tag[1]));
+ }
+
+ // Update the featured set
+ if (action === 'feature') {
+ currentFeaturedApps.add(appCoordinate);
+ } else {
+ currentFeaturedApps.delete(appCoordinate);
+ }
+
+ // Publish updated featured apps list
+ publishEvent({
+ kind: 30267,
+ content: 'Soapbox featured apps curated by moderators',
+ tags: [
+ ['d', 'soapbox-featured-apps'],
+ ['title', 'Soapbox Featured Apps'],
+ ['description', 'Apps featured in the Soapbox showcase'],
+ ...Array.from(currentFeaturedApps).map(coord => ['a', coord])
+ ],
+ created_at: Math.floor(Date.now() / 1000)
+ });
+
+ // If featuring an app, also ensure it's approved
+ if (action === 'feature') {
+ // Get current approved apps list
+ const currentApprovedLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-approved-apps'],
+ limit: 1
+ }]);
+
+ const currentApprovedList = currentApprovedLists.reduce((latest: any, current: any) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null
+ );
+
+ // Get current approved app coordinates
+ const currentApprovedApps = new Set();
+ if (currentApprovedList) {
+ currentApprovedList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => currentApprovedApps.add(tag[1]));
+ }
+
+ // Add to approved list if not already there
+ currentApprovedApps.add(appCoordinate);
+
+ // Publish updated approved apps list
+ publishEvent({
+ kind: 30267,
+ content: 'Soapbox approved apps curated by moderators',
+ tags: [
+ ['d', 'soapbox-approved-apps'],
+ ['title', 'Soapbox Approved Apps'],
+ ['description', 'Apps approved for the Soapbox showcase'],
+ ...Array.from(currentApprovedApps).map(coord => ['a', coord])
+ ],
+ created_at: Math.floor(Date.now() / 1000)
+ });
+ }
+
+ } else if (action === 'approve' || action === 'unapprove') {
+ // Get current approved apps list
+ const currentApprovedLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-approved-apps'],
+ limit: 1
+ }]);
+
+ const currentApprovedList = currentApprovedLists.reduce((latest: any, current: any) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null
+ );
+
+ // Get current approved app coordinates
+ const currentApprovedApps = new Set();
+ if (currentApprovedList) {
+ currentApprovedList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => currentApprovedApps.add(tag[1]));
+ }
+
+ // Update the approved set
+ if (action === 'approve') {
+ currentApprovedApps.add(appCoordinate);
+ } else {
+ currentApprovedApps.delete(appCoordinate);
+ }
+
+ // Publish updated approved apps list
+ publishEvent({
+ kind: 30267,
+ content: 'Soapbox approved apps curated by moderators',
+ tags: [
+ ['d', 'soapbox-approved-apps'],
+ ['title', 'Soapbox Approved Apps'],
+ ['description', 'Apps approved for the Soapbox showcase'],
+ ...Array.from(currentApprovedApps).map(coord => ['a', coord])
+ ],
+ created_at: Math.floor(Date.now() / 1000)
+ });
+
+ } else if (action === 'hide' || action === 'unhide') {
+ // Create NIP-56 report event
+ publishEvent({
+ kind: 1984,
+ content: `App ${action}den by moderator: "${app.appName}"`,
+ tags: [
+ ['a', appCoordinate, action === 'hide' ? 'spam' : 'other'],
+ ['p', app.pubkey],
+ ['L', 'soapbox.moderation'],
+ ['l', action === 'hide' ? 'hidden' : 'unhidden', 'soapbox.moderation']
+ ],
+ created_at: Math.floor(Date.now() / 1000)
+ });
+ }
+
+ // Invalidate queries to refresh the data
+ queryClient.invalidateQueries({ queryKey: ['app-submissions'] });
+
+ // If this is a Halloween app, also invalidate Halloween queries
+ if (isHalloweenSubmission) {
+ queryClient.invalidateQueries({ queryKey: ['halloween-submissions'] });
+ queryClient.invalidateQueries({ queryKey: ['halloween-submissions-with-contacts'] });
+ }
+
+ toast({
+ title: 'Success!',
+ description: `App "${app.appName}" ${action}d successfully`
+ });
+
+ } catch (error) {
+ console.error('Moderation action failed:', error);
+ toast({
+ title: 'Error',
+ description: `Failed to ${action} app "${app.appName}"`,
+ variant: 'destructive'
+ });
+ }
+ };
+
+ return (
+
+
+ {/* App Screenshot */}
+
+ {!imageError ? (
+
setImageError(true)}
+ />
+ ) : (
+
+
+
+
+
+
Screenshot unavailable
+
+
+ )}
+
+
+ {/* Actions Menu */}
+ {(isOwner || showModerationControls) && (
+
+
+
+
+
+
+ {isOwner && (
+ onEdit?.(app)}>
+
+ Edit App
+
+ )}
+ {showModerationControls && isModerator && (
+ <>
+ {isHalloweenSubmission && getContactInfo() && (getContactInfo()?.lightning || getContactInfo()?.email) && (
+
+
+ View Contact Info
+
+ )}
+ {!app.isApproved && (
+ handleModerationAction('approve')}
+ disabled={isPending}
+ >
+
+ Approve
+
+ )}
+ {app.isApproved && !app.isFeatured && (
+ handleModerationAction('unapprove')}
+ disabled={isPending}
+ >
+
+ Unapprove
+
+ )}
+ handleModerationAction(app.isFeatured ? 'unfeature' : 'feature')}
+ disabled={isPending}
+ >
+ {app.isFeatured ? (
+ <>
+
+ Un-feature
+ >
+ ) : (
+ <>
+
+ Feature
+ >
+ )}
+
+ handleModerationAction(app.isHomepage ? 'unhomepage' : 'homepage')}
+ disabled={isPending}
+ >
+ {app.isHomepage ? (
+ <>
+
+ Remove from Homepage
+ >
+ ) : (
+ <>
+
+ Add to Homepage
+ >
+ )}
+
+ handleModerationAction(app.isHidden ? 'unhide' : 'hide')}
+ disabled={isPending}
+ >
+ {app.isHidden ? (
+ <>
+
+ Unhide
+ >
+ ) : (
+ <>
+
+ Hide
+ >
+ )}
+
+ >
+ )}
+
+
+
+ )}
+
+
+
+
+
+ {/* App Icon */}
+
+

{
+ const target = e.target as HTMLImageElement;
+ target.style.display = 'none';
+ }}
+ />
+
+
+
+ {app.appName.length > 50 ? `${app.appName.slice(0, 50)}...` : app.appName}
+
+
+
+
+
+ {app.description}
+
+ {/* Author Information */}
+
+
+ {/* Spacer to push action links to bottom */}
+
+
+ {/* Action Links */}
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/src/hooks/useAppSubmissions.ts b/src/hooks/useAppSubmissions.ts
new file mode 100644
index 00000000..4bd22406
--- /dev/null
+++ b/src/hooks/useAppSubmissions.ts
@@ -0,0 +1,265 @@
+import { useNostr } from '@nostrify/react';
+import { useQuery } from '@tanstack/react-query';
+import { nip19 } from 'nostr-tools';
+import type { NostrEvent } from '@nostrify/nostrify';
+
+// Kind 31733 for app submissions (addressable events)
+const APP_SUBMISSION_KIND = 31733;
+
+// The moderator npub and hex
+const MODERATOR_NPUB = 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc';
+const MODERATOR_HEX = (() => {
+ try {
+ const decoded = nip19.decode(MODERATOR_NPUB);
+ return decoded.type === 'npub' ? decoded.data : '';
+ } catch {
+ return '';
+ }
+})();
+
+// Soapbox team follow pack naddr (same as used on About page)
+const SOAPBOX_TEAM_NADDR = 'naddr1qvzqqqyckypzpyexz3t34l966ngh5xg7u2q788hthdqmj0av3lv8s2tz9t43zt6dqqxxkdrsx4mnqm3jxfeh2ess5pyrw';
+
+export interface AppSubmission extends NostrEvent {
+ appName: string;
+ websiteUrl: string;
+ repositoryUrl: string;
+ description: string;
+ appIconUrl: string;
+ screenshotUrl: string;
+ appTags: string[];
+ authorNpub: string;
+ isFeatured: boolean;
+ isApproved: boolean;
+ isHidden: boolean;
+ isHomepage: boolean;
+}
+
+export function useAppSubmissions() {
+ const { nostr } = useNostr();
+
+ return useQuery({
+ queryKey: ['app-submissions'],
+ queryFn: async (): Promise => {
+ // Get Soapbox team follow pack for auto-approval
+ let teamPubkeys = new Set();
+ try {
+ const decoded = nip19.decode(SOAPBOX_TEAM_NADDR);
+ if (decoded.type === 'naddr') {
+ const addrData = decoded.data;
+ const teamEvents = await nostr.query([{
+ kinds: [addrData.kind],
+ authors: [addrData.pubkey],
+ '#d': [addrData.identifier],
+ limit: 1
+ }]);
+
+ if (teamEvents.length > 0) {
+ const teamEvent = teamEvents[0];
+ // Extract pubkeys from 'p' tags
+ teamEvent.tags
+ .filter(([name]) => name === 'p')
+ .forEach(([, pubkey]) => {
+ if (pubkey) teamPubkeys.add(pubkey);
+ });
+ }
+ }
+ } catch (error) {
+ console.warn('Failed to fetch Soapbox team follow pack:', error);
+ }
+
+ // Get all app submissions (kind 31733)
+ const submissionEvents = await nostr.query([{
+ kinds: [APP_SUBMISSION_KIND],
+ '#t': ['soapbox-app-submission'],
+ limit: 1000
+ }]);
+
+ // Get featured app lists from moderators (NIP-51 kind 30267)
+ const featuredLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-featured-apps'],
+ limit: 10
+ }]);
+
+ // Get approved app lists from moderators (NIP-51 kind 30267)
+ const approvedLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-approved-apps'],
+ limit: 10
+ }]);
+
+ // Get homepage app lists from moderators (NIP-51 kind 30267)
+ const homepageLists = await nostr.query([{
+ kinds: [30267],
+ authors: [MODERATOR_HEX],
+ '#d': ['soapbox-homepage-apps'],
+ limit: 10
+ }]);
+
+ // Get reporting events for hidden apps (NIP-56 kind 1984)
+ const reportEvents = await nostr.query([{
+ kinds: [1984],
+ authors: [MODERATOR_HEX],
+ limit: 1000
+ }]);
+
+ // Process submissions and apply moderation
+ const submissions: AppSubmission[] = [];
+ const submissionMap = new Map();
+
+ // Group regular submissions by d-tag (identifier) to get latest version
+ for (const event of submissionEvents) {
+ const dTag = event.tags.find(tag => tag[0] === 'd')?.[1];
+ if (!dTag) continue;
+
+ const existing = submissionMap.get(dTag);
+ if (!existing || event.created_at > existing.created_at) {
+ submissionMap.set(dTag, event);
+ }
+ }
+
+ // Get the latest featured list
+ const latestFeaturedList = featuredLists.reduce((latest, current) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null as NostrEvent | null
+ );
+
+ // Get the latest approved list
+ const latestApprovedList = approvedLists.reduce((latest, current) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null as NostrEvent | null
+ );
+
+ // Get the latest homepage list
+ const latestHomepageList = homepageLists.reduce((latest, current) =>
+ !latest || current.created_at > latest.created_at ? current : latest,
+ null as NostrEvent | null
+ );
+
+ // Extract featured app coordinates from the list
+ const featuredAppCoords = new Set();
+ if (latestFeaturedList) {
+ latestFeaturedList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => featuredAppCoords.add(tag[1]));
+ }
+
+ // Extract approved app coordinates from the list
+ const approvedAppCoords = new Set();
+ if (latestApprovedList) {
+ latestApprovedList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => approvedAppCoords.add(tag[1]));
+ }
+
+ // Extract homepage app coordinates from the list
+ const homepageAppCoords = new Set();
+ if (latestHomepageList) {
+ latestHomepageList.tags
+ .filter(tag => tag[0] === 'a')
+ .forEach(tag => homepageAppCoords.add(tag[1]));
+ }
+
+ // Get hidden app coordinates from reports
+ const hiddenAppCoords = new Set();
+ const appReports = new Map();
+
+ for (const report of reportEvents) {
+ // Look for app coordinate in 'a' tags
+ const aTag = report.tags.find(tag => tag[0] === 'a');
+ if (!aTag || !aTag[1]) continue;
+
+ const appCoord = aTag[1];
+ const reportType = aTag[2];
+
+ // Check if this is a moderation label
+ const moderationLabel = report.tags.find(tag =>
+ tag[0] === 'l' && tag[2] === 'soapbox.moderation'
+ )?.[1];
+
+ if (moderationLabel === 'hidden' && (reportType === 'spam' || reportType === 'other')) {
+ if (!appReports.has(appCoord)) {
+ appReports.set(appCoord, { hidden: 0, unhidden: 0 });
+ }
+ appReports.get(appCoord)!.hidden = Math.max(
+ appReports.get(appCoord)!.hidden,
+ report.created_at
+ );
+ } else if (moderationLabel === 'unhidden' && reportType === 'other') {
+ if (!appReports.has(appCoord)) {
+ appReports.set(appCoord, { hidden: 0, unhidden: 0 });
+ }
+ appReports.get(appCoord)!.unhidden = Math.max(
+ appReports.get(appCoord)!.unhidden,
+ report.created_at
+ );
+ }
+ }
+
+ // Determine which apps are currently hidden (latest action wins)
+ for (const [appCoord, reports] of appReports) {
+ if (reports.hidden > reports.unhidden) {
+ hiddenAppCoords.add(appCoord);
+ }
+ }
+
+ // Convert to AppSubmission objects
+ for (const [dTag, event] of submissionMap) {
+ try {
+ const appName = event.tags.find(tag => tag[0] === 'title')?.[1] || '';
+ const websiteUrl = event.tags.find(tag => tag[0] === 'website')?.[1] || '';
+ const repositoryUrl = event.tags.find(tag => tag[0] === 'repository')?.[1] || '';
+ const appIconUrl = event.tags.find(tag => tag[0] === 'icon')?.[1] || '';
+ const screenshotUrl = event.tags.find(tag => tag[0] === 'screenshot')?.[1] || '';
+ const authorNpub = event.tags.find(tag => tag[0] === 'author')?.[1] || event.pubkey;
+ const appTags = event.tags.filter(tag => tag[0] === 'app-tag').map(tag => tag[1]);
+
+ // Check if app is featured, approved, homepage, or hidden
+ const appCoordinate = `${APP_SUBMISSION_KIND}:${event.pubkey}:${dTag}`;
+ const isFeatured = featuredAppCoords.has(appCoordinate);
+ const isHomepage = homepageAppCoords.has(appCoordinate);
+ const isSubmittedByModerator = event.pubkey === MODERATOR_HEX;
+ const isSubmittedByTeamMember = teamPubkeys.has(event.pubkey);
+ const isApproved = approvedAppCoords.has(appCoordinate) || isFeatured || isSubmittedByModerator || isSubmittedByTeamMember;
+ const isHidden = hiddenAppCoords.has(appCoordinate);
+
+ submissions.push({
+ ...event,
+ appName,
+ websiteUrl,
+ repositoryUrl,
+ description: event.content,
+ appIconUrl,
+ screenshotUrl,
+ appTags: appTags,
+ authorNpub,
+ isFeatured,
+ isApproved,
+ isHidden,
+ isHomepage
+ });
+ } catch (error) {
+ console.warn('Failed to parse app submission:', error);
+ }
+ }
+
+ return submissions;
+ },
+ staleTime: 30000, // 30 seconds
+ refetchInterval: 60000, // 1 minute
+ });
+}
+
+export function useUserAppSubmissions(userPubkey?: string) {
+ const { data: allSubmissions, ...rest } = useAppSubmissions();
+
+ const userSubmissions = allSubmissions?.filter(app => app.pubkey === userPubkey) || [];
+
+ return {
+ data: userSubmissions,
+ ...rest
+ };
+}
\ No newline at end of file
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index bd0c391d..bc146526 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -4,3 +4,15 @@ import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
+
+/**
+ * Shuffles an array using the Fisher-Yates algorithm
+ */
+export function shuffleArray(array: T[]): T[] {
+ const shuffled = [...array];
+ for (let i = shuffled.length - 1; i > 0; i--) {
+ const j = Math.floor(Math.random() * (i + 1));
+ [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
+ }
+ return shuffled;
+}
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx
index 96a7a755..e0e5ac9f 100644
--- a/src/pages/Index.tsx
+++ b/src/pages/Index.tsx
@@ -23,6 +23,7 @@ import { FileAttachment } from '@/components/ui/file-attachment';
import { ArrowUp } from 'lucide-react';
import { useSeoMeta } from '@unhead/react';
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
+import { AppShowcase } from '@/components/AppShowcase';
export default function Index() {
const { t } = useTranslation();
@@ -375,6 +376,9 @@ export default function Index() {
+
+ {/* App Showcase */}
+
{/* Onboarding Dialog */}