Unlock everything, add a donation link, credit Last.fm, nudge re-linking
- Every feature is free for everyone (the plan system stays for later); remaining limits are abuse guards - Optional website donation link (NEXT_PUBLIC_DONATION_URL). Not shown in the mobile apps, where tips to the developer generally need in-app purchase - Last.fm/ListenBrainz-sourced plays link to the user's profile, as Last.fm's API terms require - Connections track when they last saw activity; a scrobbler silent for over a week prompts re-linking Spotify (its link expires every 6 months) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { router } from 'expo-router';
|
||||
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
||||
import { Linking, Pressable, StyleSheet, Text, View } from 'react-native';
|
||||
import { SERVICE_LABELS, timeAgo, type NowPlayingDTO, type StreamingService } from '@musicshare/shared';
|
||||
import { colors, space } from '@/lib/theme';
|
||||
import { Avatar } from './Avatar';
|
||||
@@ -34,7 +34,12 @@ export function NowPlayingCard({
|
||||
{np.isPlaying && <View style={styles.dot} />}
|
||||
<Text style={[styles.status, np.isPlaying && { color: colors.live }]} numberOfLines={1}>
|
||||
{np.isPlaying ? 'Listening now' : `Played ${timeAgo(np.updatedAt)}`}
|
||||
<Text style={styles.via}> · {np.sourceApp ?? SERVICE_LABELS[np.source]}</Text>
|
||||
<Text
|
||||
style={[styles.via, np.sourceUrl && styles.viaLink]}
|
||||
onPress={np.sourceUrl ? () => Linking.openURL(np.sourceUrl!) : undefined}>
|
||||
{' · '}
|
||||
{np.sourceApp ?? SERVICE_LABELS[np.source]}
|
||||
</Text>
|
||||
</Text>
|
||||
{onTogglePin && (
|
||||
<Pressable
|
||||
@@ -61,5 +66,6 @@ const styles = StyleSheet.create({
|
||||
dot: { width: 8, height: 8, borderRadius: 4, backgroundColor: colors.live },
|
||||
status: { color: colors.muted, fontSize: 13 },
|
||||
via: { color: colors.muted },
|
||||
viaLink: { textDecorationLine: 'underline' },
|
||||
pin: { color: colors.muted, fontSize: 20, marginLeft: space.xs },
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@ export function ProfileView({ username, edges }: { username: string; edges?: ('t
|
||||
<Body muted>Nothing playing right now.</Body>
|
||||
)}
|
||||
|
||||
<RecentPlays plays={profile.recent} preferred={me?.preferredService} />
|
||||
<RecentPlays plays={profile.recent} preferred={me?.preferredService} attribution={profile.attribution} />
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import { Image } from 'expo-image';
|
||||
import { Linking, Pressable, StyleSheet, Text, View } from 'react-native';
|
||||
import { openUrl, timeAgo, type RecentPlayDTO, type StreamingService } from '@musicshare/shared';
|
||||
import { openUrl, timeAgo, type ProfileDTO, type RecentPlayDTO, type StreamingService } from '@musicshare/shared';
|
||||
import { showError } from '@/lib/errors';
|
||||
import { colors, radius, space } from '@/lib/theme';
|
||||
import { Card, Heading } from './ui';
|
||||
|
||||
export function RecentPlays({ plays, preferred }: { plays: RecentPlayDTO[]; preferred: StreamingService | null | undefined }) {
|
||||
export function RecentPlays({
|
||||
plays,
|
||||
preferred,
|
||||
attribution = {},
|
||||
}: {
|
||||
plays: RecentPlayDTO[];
|
||||
preferred: StreamingService | null | undefined;
|
||||
attribution?: ProfileDTO['attribution'];
|
||||
}) {
|
||||
const credits = (['lastfm', 'listenbrainz'] as const).filter((s) => attribution[s] && plays.some((p) => p.source === s));
|
||||
if (plays.length === 0) return null;
|
||||
return (
|
||||
<Card style={{ gap: 0 }}>
|
||||
@@ -35,6 +44,11 @@ export function RecentPlays({ plays, preferred }: { plays: RecentPlayDTO[]; pref
|
||||
<Text style={styles.time}>{timeAgo(p.playedAt)}</Text>
|
||||
</Pressable>
|
||||
))}
|
||||
{credits.map((s) => (
|
||||
<Text key={s} style={styles.credit} onPress={() => Linking.openURL(attribution[s]!)}>
|
||||
Some plays via <Text style={{ textDecorationLine: 'underline' }}>{s === 'lastfm' ? 'Last.fm' : 'ListenBrainz'}</Text>
|
||||
</Text>
|
||||
))}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -47,4 +61,5 @@ const styles = StyleSheet.create({
|
||||
title: { color: colors.text, fontWeight: '600', fontSize: 14 },
|
||||
artist: { color: colors.muted, fontSize: 13 },
|
||||
time: { color: colors.muted, fontSize: 12 },
|
||||
credit: { color: colors.muted, fontSize: 12, marginTop: space.sm },
|
||||
});
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as WebBrowser from 'expo-web-browser';
|
||||
import useSWR from 'swr';
|
||||
import { SERVICE_LABELS, SPOTIFY_LINK_PAGES, isQuietScrobbler, type ConnectionDTO } from '@musicshare/shared';
|
||||
import { Body, Button, Card } from './ui';
|
||||
|
||||
/** Nudge when Last.fm/ListenBrainz has gone quiet: usually Spotify's 6-month link expired. */
|
||||
export function RelinkReminder() {
|
||||
const { data: connections = [] } = useSWR<ConnectionDTO[]>('/connections');
|
||||
const quiet = connections.find((c) => isQuietScrobbler(c));
|
||||
if (!quiet || !isQuietScrobbler(quiet)) return null;
|
||||
const name = SERVICE_LABELS[quiet.provider];
|
||||
return (
|
||||
<Card>
|
||||
<Body>
|
||||
Nothing new from {name} in over a week. If you listen on Spotify, its link to {name} expires every 6 months.
|
||||
Re-link it to keep sharing.
|
||||
</Body>
|
||||
<Button
|
||||
small
|
||||
variant="primary"
|
||||
title={`Re-link Spotify on ${name}`}
|
||||
onPress={() => WebBrowser.openBrowserAsync(SPOTIFY_LINK_PAGES[quiet.provider])}
|
||||
style={{ alignSelf: 'flex-start' }}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user