videogen/apps/mobile/app/r/[token].tsx
caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

151 lines
4.8 KiB
TypeScript

/**
* Route: /r/[token] — a public reel share link opened in the app
* (menivor://r/<token>, or https://menivor.com/r/<token> via universal / app
* links). Resolves the token with the unauthenticated GET /public/r/{token} and
* plays the watermarked preview; the payload never carries private fields.
*/
import { useCallback, useEffect, useState } from "react";
import {
ActivityIndicator,
Pressable,
ScrollView,
StyleSheet,
Text,
View,
} from "react-native";
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
import { ApiError, getPublicShare } from "@/lib/api";
import type { SharePublic } from "@/lib/types";
import { useSession } from "@/src/shared/auth";
import { JobVideo } from "@/src/shared/media";
import { colors, radius, spacing, typeScale } from "@/src/shared/theme";
type LoadState =
| { status: "loading" }
| { status: "ready"; share: SharePublic }
| { status: "missing" }
| { status: "error"; message: string };
export default function PublicShareScreen() {
const params = useLocalSearchParams<{ token?: string | string[] }>();
const token = (Array.isArray(params.token) ? params.token[0] : params.token) ?? "";
const { apiKey } = useSession();
const router = useRouter();
const [state, setState] = useState<LoadState>({ status: "loading" });
const load = useCallback(async () => {
if (!token.trim()) {
setState({ status: "missing" });
return;
}
setState({ status: "loading" });
try {
setState({ status: "ready", share: await getPublicShare(token.trim()) });
} catch (err) {
if (err instanceof ApiError && err.status === 404) {
setState({ status: "missing" });
return;
}
setState({
status: "error",
message:
err instanceof ApiError
? err.message
: "Could not load this reel. Check your connection and try again.",
});
}
}, [token]);
useEffect(() => {
void load();
}, [load]);
const onMakeYourOwn = () => {
router.replace(apiKey ? "/(tabs)/create" : "/");
};
return (
<ScrollView style={styles.container} contentContainerStyle={styles.content}>
<Stack.Screen options={{ title: "Shared reel", headerShown: true }} />
{state.status === "loading" ? (
<View style={styles.center}>
<ActivityIndicator color={colors.accent} size="large" />
</View>
) : state.status === "missing" ? (
<View style={styles.card}>
<Text style={styles.title}>This link is no longer available</Text>
<Text style={styles.body}>
The creator may have revoked it, or the reel was removed.
</Text>
</View>
) : state.status === "error" ? (
<View style={styles.card}>
<Text style={styles.title}>Could not load this reel</Text>
<Text style={styles.body}>{state.message}</Text>
<Pressable
style={styles.secondary}
onPress={() => void load()}
accessibilityRole="button"
>
<Text style={styles.secondaryText}>Try again</Text>
</Pressable>
</View>
) : (
<>
<Text style={styles.title}>{state.share.title || "Untitled reel"}</Text>
{state.share.created_at ? (
<Text style={styles.meta}>
{new Date(state.share.created_at).toLocaleDateString()}
</Text>
) : null}
<JobVideo uri={state.share.watermarked_preview_url} isLooping />
</>
)}
<Pressable
style={styles.primary}
onPress={onMakeYourOwn}
accessibilityRole="button"
>
<Text style={styles.primaryText}>Make your own reel</Text>
</Pressable>
</ScrollView>
);
}
const styles = StyleSheet.create({
container: { flex: 1, backgroundColor: colors.bg },
content: { padding: spacing.xl, gap: spacing.md },
center: { paddingVertical: 80, alignItems: "center" },
card: {
backgroundColor: colors.surface,
borderColor: colors.border,
borderWidth: 1,
borderRadius: radius.lg,
padding: spacing.lg,
gap: spacing.sm,
},
title: { color: colors.textPrimary, fontSize: typeScale.heading, fontWeight: "800" },
body: { color: colors.textSecondary, fontSize: typeScale.body, lineHeight: 21 },
meta: { color: colors.textFaint, fontSize: typeScale.caption },
primary: {
backgroundColor: colors.accent,
borderRadius: radius.md,
paddingVertical: 14,
alignItems: "center",
marginTop: spacing.sm,
},
primaryText: { color: colors.onAccent, fontSize: typeScale.body, fontWeight: "700" },
secondary: {
borderColor: colors.border,
borderWidth: 1,
borderRadius: radius.md,
paddingVertical: 12,
alignItems: "center",
},
secondaryText: { color: colors.textPrimary, fontSize: typeScale.body, fontWeight: "600" },
});