|
1 | 1 | import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'; |
2 | | -import { showError } from './error'; |
3 | | -import { errorDetails } from '../util/errorDetails'; |
4 | 2 | import { |
5 | 3 | createUpload, |
6 | 4 | deleteSubtitleFile, |
7 | 5 | uploadParts, |
8 | 6 | uploadSubtitleFile |
9 | 7 | } from '../services/UploadsApi'; |
| 8 | +import { errorDetails } from '../util/errorDetails'; |
| 9 | +import { showError } from './error'; |
10 | 10 |
|
11 | 11 | export type YouTubeAsset = { id: string; sources?: undefined }; |
12 | 12 | export type SelfHostedAsset = { id?: undefined; sources: unknown[] }; |
@@ -39,19 +39,21 @@ export const startVideoUpload = createAsyncThunk< |
39 | 39 | unknown, |
40 | 40 | { id: string; file: File; selfHost?: boolean } |
41 | 41 | >('s3Upload/startVideoUpload', ({ id, file, selfHost }, { dispatch }) => |
42 | | - createUpload(id, file, selfHost).then((upload: Upload) => { |
43 | | - dispatch(s3UploadStarted(upload)); |
| 42 | + createUpload(id, file, selfHost) |
| 43 | + .then((upload: Upload) => { |
| 44 | + dispatch(s3UploadStarted(upload)); |
44 | 45 |
|
45 | | - const progress = (completed: number) => |
46 | | - dispatch(s3UploadProgress(completed)); |
| 46 | + const progress = (completed: number) => |
| 47 | + dispatch(s3UploadProgress(completed)); |
47 | 48 |
|
48 | | - return uploadParts(upload, upload.parts, file, progress) |
49 | | - .then(() => dispatch(setS3UploadStatusToComplete())) |
50 | | - .catch(err => { |
51 | | - dispatch(showError(errorDetails(err), err)); |
52 | | - dispatch(setS3UploadStatusToError()); |
53 | | - }); |
54 | | - }) |
| 49 | + return uploadParts(upload, upload.parts, file, progress).then(() => |
| 50 | + dispatch(setS3UploadStatusToComplete()) |
| 51 | + ); |
| 52 | + }) |
| 53 | + .catch(err => { |
| 54 | + dispatch(showError(errorDetails(err), err)); |
| 55 | + dispatch(setS3UploadStatusToError()); |
| 56 | + }) |
55 | 57 | ); |
56 | 58 |
|
57 | 59 | export const startSubtitleFileUpload = createAsyncThunk< |
|
0 commit comments