diff --git a/packages/atlas/src/components/_inputs/SubtitlesBox/SubtitlesBox.tsx b/packages/atlas/src/components/_inputs/SubtitlesBox/SubtitlesBox.tsx index ff2b67aae4..4e11e7c292 100644 --- a/packages/atlas/src/components/_inputs/SubtitlesBox/SubtitlesBox.tsx +++ b/packages/atlas/src/components/_inputs/SubtitlesBox/SubtitlesBox.tsx @@ -10,7 +10,9 @@ import { ContextMenu } from '@/components/_overlays/ContextMenu' import { atlasConfig } from '@/config' import { useGetAssetUrl } from '@/hooks/useGetAssetUrl' import { useConfirmationModal } from '@/providers/confirmationModal' +import { useSnackbar } from '@/providers/snackbars' import { SubtitlesInput } from '@/types/subtitles' +import { SentryLogger } from '@/utils/logs' import { InvisibleInput, @@ -39,6 +41,7 @@ export const SubtitlesBox: FC = ({ }) => { const inputRef = useRef(null) const [openUnsuportedFileDialog, closeUnsuportedFileDialog] = useConfirmationModal() + const { displaySnackbar } = useSnackbar() const hasFile = !!file || !!id const { mutateAsync: subtitlesFetch } = useMutation('subtitles-fetch', (url: string) => axiosInstance.get(url, { responseType: 'blob' }) @@ -46,14 +49,22 @@ export const SubtitlesBox: FC = ({ const { url } = useGetAssetUrl(asset?.resolvedUrls, 'subtitle') const handleDownload = async (url = '') => { - const response = await subtitlesFetch(url) - const objectURL = window.URL.createObjectURL(new Blob([response.data])) - const link = document.createElement('a') - link.href = objectURL - link.setAttribute('download', `${id}-${languageIso.toLowerCase()}.vtt`) - document.body.appendChild(link) - link.click() - document.body.removeChild(link) + try { + const response = await subtitlesFetch(url) + const objectURL = window.URL.createObjectURL(new Blob([response.data])) + const link = document.createElement('a') + link.href = objectURL + link.setAttribute('download', `${id}-${languageIso.toLowerCase()}.vtt`) + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + } catch (error) { + SentryLogger.error('Failed to fetch subtitles for download', 'handleDownload', error) + displaySnackbar({ + title: 'Failed to connect to distributor', + iconType: 'error', + }) + } } const contexMenuItems: ListItemProps[] = [ diff --git a/packages/atlas/src/providers/assets/assets.helpers.ts b/packages/atlas/src/providers/assets/assets.helpers.ts index 5103bcc6df..aefff2e0d2 100644 --- a/packages/atlas/src/providers/assets/assets.helpers.ts +++ b/packages/atlas/src/providers/assets/assets.helpers.ts @@ -112,11 +112,13 @@ export const logDistributorPerformance = async (assetUrl: string, eventEntry: Di export const getFastestImageUrl = async (urls: string[]) => { const promises = urls.map((url) => { - return axiosInstance.head(url, { - headers: { - 'Cache-Control': 'no-cache', - }, - }) + return axiosInstance + .head(url, { + headers: { + 'Cache-Control': 'no-cache', + }, + }) + .catch((error) => ConsoleLogger.warn('Failed while performing performance download', error)) }) return Promise.race(promises) } diff --git a/packages/atlas/src/providers/auth/auth.helpers.ts b/packages/atlas/src/providers/auth/auth.helpers.ts index d2f7d6de66..a032f0c350 100644 --- a/packages/atlas/src/providers/auth/auth.helpers.ts +++ b/packages/atlas/src/providers/auth/auth.helpers.ts @@ -12,7 +12,7 @@ import { atlasConfig } from '@/config' import { ORION_AUTH_URL } from '@/config/env' import { keyring } from '@/joystream-lib/lib' import { getWalletsList } from '@/providers/wallet/wallet.helpers' -import { SentryLogger } from '@/utils/logs' +import { ConsoleLogger, SentryLogger } from '@/utils/logs' import { withTimeout } from '@/utils/misc' import { AuthModals, LogInErrors, OrionAccountError, RegisterParams, RegisterPayload } from './auth.types' @@ -104,7 +104,7 @@ export const decodeSessionEncodedSeedToMnemonic = async (encodedSeed: string) => return _entropyToMnemonic(Buffer.from(decryptedSeed.slice(2, decryptedSeed.length), 'hex')) } catch (e) { if (isAxiosError(e) && e.response?.data.message === 'isAxiosError') { - logoutRequest() + logoutRequest().catch((error) => ConsoleLogger.warn('Failed to logout on decoding error', error)) } return null } @@ -269,8 +269,7 @@ export const getMnemonicFromeEmailAndPassword = async (email: string, password: if (!data?.decryptedEntropy) { throw Error("Couldn't fetch artifacts") } - const mnemonic = entropyToMnemonic(data?.decryptedEntropy) - return mnemonic + return entropyToMnemonic(data?.decryptedEntropy) } export const getAuthEpoch = async () => {