diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx index c2e7f8f..1768a1f 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx @@ -49,7 +49,7 @@ import type { BrowsePlaylistDetail, BrowseSong } from "@otunes/convex/types" import type { CoverPalette } from "@/lib/cover-palette" import { longListProps } from "@/lib/list" import { rememberSongs } from "@/lib/song-cache" -import { showError, showSuccess } from "@/lib/toast" +import { showError } from "@/lib/toast" import { playlistCoverUrl } from "@/lib/urls" import { radius, spacing, useThemeColors } from "@/lib/theme" @@ -206,7 +206,6 @@ function PlaylistContent({ if (!playlistId) return false try { await removeSongs({ playlistId, songIds: [songId] }) - showSuccess("Removed from playlist") return true } catch (error) { showError( @@ -233,10 +232,8 @@ function PlaylistContent({ try { if (isSubscribed) { await unsubscribe({ playlistId }) - showSuccess("Unsubscribed") } else { await subscribe({ playlistId }) - showSuccess("Subscribed") } } catch (error) { showError( @@ -250,7 +247,6 @@ function PlaylistContent({ if (!playlistId) return try { await deletePlaylist({ playlistId }) - showSuccess("Playlist deleted") router.back() } catch (error) { showError( diff --git a/apps/mobile/app/(app)/(tabs)/home/settings.tsx b/apps/mobile/app/(app)/(tabs)/home/settings.tsx index 9d15405..80e6a13 100644 --- a/apps/mobile/app/(app)/(tabs)/home/settings.tsx +++ b/apps/mobile/app/(app)/(tabs)/home/settings.tsx @@ -22,7 +22,7 @@ import { initialsFromName } from "@/lib/format" import { useCachedQuery } from "@/hooks/use-cached-query" import { clearLocalData, signOutToSignIn } from "@/lib/session" import { radius, spacing, useThemeColors } from "@/lib/theme" -import { showError, showSuccess } from "@/lib/toast" +import { showError } from "@/lib/toast" import type { PlaybackQuality } from "@/lib/urls" import { api } from "@otunes/convex/_generated/api" import type { Id } from "@otunes/convex/_generated/dataModel" @@ -179,7 +179,6 @@ function ProfileSection({ user }: { user: CurrentUser }) { await updateImage({ image: `data:${mime};base64,${result.assets[0].base64}`, }) - showSuccess("Profile photo updated") } catch (error) { showError( error instanceof Error ? error.message : "Failed to update photo" @@ -190,7 +189,6 @@ function ProfileSection({ user }: { user: CurrentUser }) { async function removeImage() { try { await updateImage({ image: null }) - showSuccess("Profile photo removed") } catch (error) { showError( error instanceof Error ? error.message : "Failed to remove photo" @@ -209,7 +207,6 @@ function ProfileSection({ user }: { user: CurrentUser }) { await updatePassword({ newPassword }) setNewPassword("") setConfirmPassword("") - showSuccess("Password updated") } catch (error) { showError( error instanceof Error ? error.message : "Failed to update password" @@ -258,9 +255,8 @@ function ProfileSection({ user }: { user: CurrentUser }) { variant="secondary" disabled={name.trim() === user.name} onPress={() => - void updateName({ name: name.trim() }).then( - () => showSuccess("Name updated"), - (error: Error) => showError(error.message) + void updateName({ name: name.trim() }).catch((error: Error) => + showError(error.message) ) } /> @@ -279,9 +275,8 @@ function ProfileSection({ user }: { user: CurrentUser }) { variant="secondary" disabled={email.trim() === user.email} onPress={() => - void updateEmail({ email: email.trim() }).then( - () => showSuccess("Email updated"), - (error: Error) => showError(error.message) + void updateEmail({ email: email.trim() }).catch((error: Error) => + showError(error.message) ) } /> @@ -407,7 +402,6 @@ function LibrarySection() { setUpdating(true) try { await updateLibrary({}) - showSuccess("Library updated") } catch (error) { showError( error instanceof Error @@ -427,8 +421,7 @@ function LibrarySection() { onPress={async () => { setCleaningHls(true) try { - const result = await cleanupHlsStreams({}) - showSuccess(`Removed ${result.removed} idle HLS streams`) + await cleanupHlsStreams({}) } catch (error) { showError( error instanceof Error @@ -529,10 +522,7 @@ function UsersSection({ void setAdmin({ userId: user._id, isAdmin: !user.isAdmin, - }).then( - () => showSuccess("Updated permissions"), - (error: Error) => showError(error.message) - ) + }).catch((error: Error) => showError(error.message)) } style={styles.userActionButton} /> @@ -540,8 +530,7 @@ function UsersSection({ title="Delete" variant="destructive" onPress={() => - void deleteUserMutation({ userId: user._id }).then( - () => showSuccess("User deleted"), + void deleteUserMutation({ userId: user._id }).catch( (error: Error) => showError(error.message) ) } diff --git a/apps/mobile/contexts/add-to-playlist.tsx b/apps/mobile/contexts/add-to-playlist.tsx index ed4d1d6..e6db05a 100644 --- a/apps/mobile/contexts/add-to-playlist.tsx +++ b/apps/mobile/contexts/add-to-playlist.tsx @@ -25,8 +25,8 @@ import { fetchCachedQuery } from "@otunes/convex/client/cached-query" import { api } from "@otunes/convex/_generated/api" import type { OwnedPlaylistForAdd } from "@otunes/convex/types" import type { Id } from "@otunes/convex/_generated/dataModel" -import { showError, showSuccess } from "@/lib/toast" import { useAppNavigation } from "@/lib/app-navigation" +import { showError } from "@/lib/toast" import { useThemeColors } from "@/lib/theme" type AddToPlaylistContextValue = { @@ -169,27 +169,17 @@ export function AddToPlaylistProvider({ children }: { children: ReactNode }) { }, []) const handleAddToPlaylist = useCallback( - async ( - playlistId: Id<"playlists">, - title: string, - existing: Id<"songs">[] - ) => { + async (playlistId: Id<"playlists">, existing: Id<"songs">[]) => { if (addingToPlaylistId) return const existingSet = new Set(existing) const toAdd = pendingSongIds.filter((id) => !existingSet.has(id)) if (toAdd.length === 0) { - showSuccess(`All selected songs are already in ${title}`) closeAddToPlaylist() return } setAddingToPlaylistId(playlistId) try { await addSongs({ playlistId, songIds: toAdd }) - showSuccess( - toAdd.length > 1 - ? `Added ${toAdd.length} songs to ${title}` - : `Added to ${title}` - ) closeAddToPlaylist() } catch (error) { showError( @@ -211,7 +201,6 @@ export function AddToPlaylistProvider({ children }: { children: ReactNode }) { name, songIds: pendingSongIds, }) - showSuccess("Playlist created") setCreateOpen(false) closeAddToPlaylist() push(`/playlist/${playlistId}`) @@ -281,11 +270,7 @@ export function AddToPlaylistProvider({ children }: { children: ReactNode }) { style={styles.row} disabled={addingToPlaylistId !== null} onPress={() => - void handleAddToPlaylist( - playlist.id, - playlist.title, - playlist.songIds - ) + void handleAddToPlaylist(playlist.id, playlist.songIds) } > diff --git a/apps/mobile/contexts/favorites.tsx b/apps/mobile/contexts/favorites.tsx index 0c7829b..f07a2b6 100644 --- a/apps/mobile/contexts/favorites.tsx +++ b/apps/mobile/contexts/favorites.tsx @@ -13,7 +13,7 @@ import { import { useCachedQuery } from "@/hooks/use-cached-query" import { api } from "@otunes/convex/_generated/api" import type { Id } from "@otunes/convex/_generated/dataModel" -import { showError, showSuccess } from "@/lib/toast" +import { showError } from "@/lib/toast" /** * `useMutation(...).withOptimisticUpdate(...)` with a stable identity. The @@ -178,10 +178,8 @@ export function FavoritesProvider({ children }: { children: ReactNode }) { try { if (idsRef.current.songIds.has(songId)) { await unfavoriteSong({ songId }) - showSuccess("Removed from favorites") } else { await favoriteSong({ songId }) - showSuccess("Added to favorites") } } catch (error) { showError( @@ -197,10 +195,8 @@ export function FavoritesProvider({ children }: { children: ReactNode }) { try { if (idsRef.current.albumIds.has(albumId)) { await unfavoriteAlbum({ albumId }) - showSuccess("Removed from favorites") } else { await favoriteAlbum({ albumId }) - showSuccess("Added to favorites") } } catch (error) { showError( @@ -216,10 +212,8 @@ export function FavoritesProvider({ children }: { children: ReactNode }) { try { if (idsRef.current.artistIds.has(artistId)) { await unfavoriteArtist({ artistId }) - showSuccess("Removed from favorites") } else { await favoriteArtist({ artistId }) - showSuccess("Added to favorites") } } catch (error) { showError( @@ -236,11 +230,6 @@ export function FavoritesProvider({ children }: { children: ReactNode }) { if (unique.length === 0) return try { await favoriteSongsMutation({ songIds: unique }) - showSuccess( - unique.length > 1 - ? `Favorited ${unique.length} songs` - : "Added to favorites" - ) } catch (error) { showError( error instanceof Error ? error.message : "Failed to update favorites" diff --git a/apps/mobile/hooks/use-media-menu-actions.ts b/apps/mobile/hooks/use-media-menu-actions.ts index 8aecdb0..21fac0f 100644 --- a/apps/mobile/hooks/use-media-menu-actions.ts +++ b/apps/mobile/hooks/use-media-menu-actions.ts @@ -7,7 +7,7 @@ import { useCacheScope } from "@/contexts/persistent-cache" import { useFavorites } from "@/contexts/favorites" import { usePlaybackActions } from "@/contexts/playback" import { useAppNavigation } from "@/lib/app-navigation" -import { showError, showSuccess } from "@/lib/toast" +import { showError } from "@/lib/toast" import { api } from "@otunes/convex/_generated/api" import { fetchCachedQuery } from "@otunes/convex/client/cached-query" import type { Id } from "@otunes/convex/_generated/dataModel" @@ -55,11 +55,9 @@ export function useMediaMenuActions() { switch (action) { case "play-next": await addToQueueNext(songIds) - showSuccess("Queued to play next") break case "play-last": await addToQueueLast(songIds) - showSuccess("Queued to play last") break case "shuffle": await playShuffled(songIds) diff --git a/apps/mobile/lib/toast.ts b/apps/mobile/lib/toast.ts index b04ac23..c647b09 100644 --- a/apps/mobile/lib/toast.ts +++ b/apps/mobile/lib/toast.ts @@ -1,13 +1,5 @@ import { toast } from "sonner-native" -export function showToast(message: string) { - toast(message) -} - export function showError(message: string) { toast.error(message) } - -export function showSuccess(message: string) { - toast.success(message) -}