.failed fetch pop up
This commit is contained in:
@@ -629,6 +629,33 @@ function App() {
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
<Dialog open={metadata.showVpnAdviceDialog} onOpenChange={metadata.setShowVpnAdviceDialog}>
|
||||||
|
<DialogContent className="max-w-md [&>button]:hidden">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Fetch Failed</DialogTitle>
|
||||||
|
<DialogDescription className="space-y-3">
|
||||||
|
<span className="block">
|
||||||
|
Metadata fetch failed. Try using a high-quality VPN such as
|
||||||
|
Surfshark, ExpressVPN, Proton VPN, or a similar service.
|
||||||
|
</span>
|
||||||
|
<span className="block">
|
||||||
|
Choose a location that is not blocked by Spotify or the
|
||||||
|
related service, such as the USA, UK, Germany, Netherlands,
|
||||||
|
or Singapore.
|
||||||
|
</span>
|
||||||
|
<span className="block">
|
||||||
|
If you are already using a VPN, try switching to another
|
||||||
|
server and fetch again.
|
||||||
|
</span>
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button onClick={() => metadata.setShowVpnAdviceDialog(false)}>
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
<Dialog open={isFFmpegInstalled === false} onOpenChange={() => { }}>
|
<Dialog open={isFFmpegInstalled === false} onOpenChange={() => { }}>
|
||||||
<DialogContent className="max-w-[450px] [&>button]:hidden p-6 gap-5">
|
<DialogContent className="max-w-[450px] [&>button]:hidden p-6 gap-5">
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import type { SpotifyMetadataResponse } from "@/types/api";
|
|||||||
export function useMetadata() {
|
export function useMetadata() {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [metadata, setMetadata] = useState<SpotifyMetadataResponse | null>(null);
|
const [metadata, setMetadata] = useState<SpotifyMetadataResponse | null>(null);
|
||||||
|
const [showVpnAdviceDialog, setShowVpnAdviceDialog] = useState(false);
|
||||||
|
const [fetchFailureReason, setFetchFailureReason] = useState("");
|
||||||
const loadingToastId = useRef<string | number | null>(null);
|
const loadingToastId = useRef<string | number | null>(null);
|
||||||
const fetchedCount = useRef(0);
|
const fetchedCount = useRef(0);
|
||||||
const currentName = useRef("");
|
const currentName = useRef("");
|
||||||
@@ -18,6 +20,10 @@ export function useMetadata() {
|
|||||||
external_urls: string;
|
external_urls: string;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
const [pendingArtistName, setPendingArtistName] = useState<string | null>(null);
|
const [pendingArtistName, setPendingArtistName] = useState<string | null>(null);
|
||||||
|
const showFetchFailureAdvice = (errorMsg: string) => {
|
||||||
|
setFetchFailureReason(errorMsg);
|
||||||
|
setShowVpnAdviceDialog(true);
|
||||||
|
};
|
||||||
const resolveArtistUrlBySearch = async (artistName: string): Promise<string | null> => {
|
const resolveArtistUrlBySearch = async (artistName: string): Promise<string | null> => {
|
||||||
const query = artistName.trim();
|
const query = artistName.trim();
|
||||||
if (!query) {
|
if (!query) {
|
||||||
@@ -214,6 +220,7 @@ export function useMetadata() {
|
|||||||
const errorMsg = err instanceof Error ? err.message : "Failed to fetch metadata";
|
const errorMsg = err instanceof Error ? err.message : "Failed to fetch metadata";
|
||||||
logger.error(`fetch failed: ${errorMsg}`);
|
logger.error(`fetch failed: ${errorMsg}`);
|
||||||
toast.error(errorMsg);
|
toast.error(errorMsg);
|
||||||
|
showFetchFailureAdvice(errorMsg);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -316,6 +323,7 @@ export function useMetadata() {
|
|||||||
const errorMsg = err instanceof Error ? err.message : "Failed to fetch album metadata";
|
const errorMsg = err instanceof Error ? err.message : "Failed to fetch album metadata";
|
||||||
logger.error(`fetch failed: ${errorMsg}`);
|
logger.error(`fetch failed: ${errorMsg}`);
|
||||||
toast.error(errorMsg);
|
toast.error(errorMsg);
|
||||||
|
showFetchFailureAdvice(errorMsg);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -325,6 +333,9 @@ export function useMetadata() {
|
|||||||
return {
|
return {
|
||||||
loading,
|
loading,
|
||||||
metadata,
|
metadata,
|
||||||
|
showVpnAdviceDialog,
|
||||||
|
setShowVpnAdviceDialog,
|
||||||
|
fetchFailureReason,
|
||||||
showAlbumDialog,
|
showAlbumDialog,
|
||||||
setShowAlbumDialog,
|
setShowAlbumDialog,
|
||||||
selectedAlbum,
|
selectedAlbum,
|
||||||
|
|||||||
Reference in New Issue
Block a user