Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion api/apps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { neon } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';
import { apps, featuredApps, bumpRules } from '../src/db/schema';
import { apps, featuredApps, bumpRules, appSubmissions } from '../src/db/schema';
import { eq, desc, and, gte, lte } from 'drizzle-orm';

export const config = {
Expand Down Expand Up @@ -31,6 +31,34 @@ export default async function handler(_request: Request) {
.orderBy(desc(apps.frequency));
const allApps = allAppsRaw.map(normalizeOpalLogo);

// Get all approved submissions
const approvedSubmissions = await db
.select()
.from(appSubmissions)
.where(eq(appSubmissions.status, 'approved'))
.orderBy(desc(appSubmissions.submittedAt));
Comment on lines +34 to +39
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/api/apps now returns approved UGC submissions mixed in with official apps. This endpoint is also used as the source of truth for pinning/autocomplete flows that assume IDs exist in the apps table (e.g. profile “Add to profile and homepage” and /api/profile/add-app validates against apps). As-is, a user can select/pin a submission ID and hit 404/lose the pin in management views. Consider either (1) keeping /api/apps as official-only and adding a separate endpoint (or query param) for “homepage apps incl. submissions”, or (2) returning a distinct identifier/type for submissions and updating consumers to filter to isOfficial for pin/autocomplete.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback


// Transform submissions to match App interface
const submissionsAsApps = approvedSubmissions.map((s) => ({
id: s.id,
name: s.name,
slug: `ugc-${s.id}`,
url: s.url,
logoUrl: s.logoUrl,
description: s.description,
tagline: null,
category: s.category || 'Other',
tags: [],
isOfficial: false,
frequency: s.clickCount || 0,
featured: false,
createdAt: s.submittedAt,
updatedAt: s.reviewedAt || s.submittedAt,
}));

// Combine both lists
const allApps = [...officialApps, ...submissionsAsApps];

// Get today's featured app (if any)
const today = new Date().toISOString().split('T')[0];
const todaysFeatured = await db
Expand Down
6 changes: 2 additions & 4 deletions api/profile/[slug].ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ export default async function handler(request: Request) {
submissionLogoUrl: appSubmissions.logoUrl,
submissionDescription: appSubmissions.description,
submissionCategory: appSubmissions.category,
submissionStatus: appSubmissions.status,
Comment on lines 94 to +97
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submissionStatus is selected from appSubmissions, but it is never surfaced in the returned apps payload (the submitted-app branch in apps_data does not include it). This means the API response still doesn't expose submission approval status as described in the PR; include the status field in the submitted app objects (and consider naming it consistently, e.g. status or submissionStatus).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

})
.from(userProfileApps)
.leftJoin(apps, eq(userProfileApps.appId, apps.id))
.leftJoin(appSubmissions, and(
eq(userProfileApps.submissionId, appSubmissions.id),
eq(appSubmissions.status, 'approved') // Only show approved submissions
))
.leftJoin(appSubmissions, eq(userProfileApps.submissionId, appSubmissions.id))
.where(and(
eq(userProfileApps.userId, profile.id),
eq(userProfileApps.isVisible, true)
Expand Down
4 changes: 2 additions & 2 deletions claude.md
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,8 @@ User on profile → Selects existing app from autocomplete
3. **Dynamic routing**: `[slug].tsx` catches all profile URLs
4. **Public by default**: Profiles are public, apps visible by default
5. **Inline controls**: Toggle visibility with immediate preview
6. **Two app sources**: Pinned apps + submitted (approved) apps
7. **Profile-specific**: Users can hide apps from profile (different from unpinning)
6. **Two app sources**: Pinned apps + submitted apps (shown immediately on profile; shown on homepage only after approval)
7. **Profile-specific**: Self-submitted apps appear immediately on the user's profile and appear on the main homepage only after approval.

#### User Flow
1. User signs in → slug auto-generated from email prefix
Expand Down