fix(mobile): remove success toasts

- Keep error toasts for failed actions
- Remove unused toast helpers and update sonner-native
This commit is contained in:
joshuafhiggins committed 2026-10-17 20:11:41 -04:00
1 parent 38add8df53
commit 8eae53e25c
7 files changed
+20 -69

No files matched your search

@@ -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(
+8 -19
View File
@@ -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)
)
}
+3 -18
View File
@@ -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)
}
>
<Text style={{ color: colors.foreground }}>
+1 -12
View File
@@ -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"
+1 -3
View File
@@ -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)
-8
View File
@@ -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)
}
+6 -4
View File
@@ -123,7 +123,7 @@ importers:
version: 0.10.0(@babel/core@7.29.7)(@react-native/metro-config@0.86.0(@babel/core@7.29.7))(react-native@0.86.0(@babel/core@7.29.7)(@react-native/metro-config@0.86.0(@babel/core@7.29.7))(@types/react@19.2.17)(react@19.2.3))(react@19.2.3)
sonner-native:
specifier: ^0.26.2
version: 0.26.4(f87ef153a90aa4f507f45f5b291157e4)
version: 0.26.5(f87ef153a90aa4f507f45f5b291157e4)
devDependencies:
'@types/node':
specifier: ^20
@@ -5914,8 +5914,8 @@ packages:
resolution: {integrity: sha512-vZ7rfeehZui7wQs438JXBckYLkIIdfHOXsaVEUMyS5fHo1483l1bMdo0EDSWYclY0yZKFOipDy4KHuKs6ssvdg==}
engines: {node: '>=8.0.0'}
sonner-native@0.26.4:
resolution: {integrity: sha512-wBE/pctNfz+ieXjpYX7uu5hH38ws8xRmH0AFmEdEgkOS363k6N8QfFoyjGqDmdUDy15m4AAvOjd2Wz/jATukIA==}
sonner-native@0.26.5:
resolution: {integrity: sha512-LlYiAryfg3Ui5eQlxwLV/Ziyaew7HTWqPvbbpUKMypGM5lcMZc0TLYTZziWAHBiMyvDLi8813KO2iMmF8C5GyQ==}
peerDependencies:
react: '*'
react-native: '*'
@@ -9050,7 +9050,9 @@ snapshots:
metro-runtime: 0.84.4
transitivePeerDependencies:
- '@babel/core'
- bufferutil
- supports-color
- utf-8-validate
'@react-native/normalize-colors@0.86.0': {}
@@ -13232,7 +13234,7 @@ snapshots:
slugify@1.6.9: {}
sonner-native@0.26.4(f87ef153a90aa4f507f45f5b291157e4):
sonner-native@0.26.5(f87ef153a90aa4f507f45f5b291157e4):
dependencies:
react: 19.2.3
react-native: 0.86.0(@babel/core@7.29.7)(@react-native/metro-config@0.86.0(@babel/core@7.29.7))(@types/react@19.2.17)(react@19.2.3)