Merge remote-tracking branch 'origin/main' into finish-pure-status-component

This commit is contained in:
Alex Gleason 2024-12-27 15:46:32 -06:00
commit 1e07105016
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
5 changed files with 28 additions and 5 deletions

View File

@ -384,7 +384,10 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) =>
f,
intl,
(data) => dispatch(uploadComposeSuccess(composeId, data, f)),
(error) => dispatch(uploadComposeFail(composeId, error)),
(error) => {
console.error(error);
dispatch(uploadComposeFail(composeId, error));
},
(e: ProgressEvent) => {
progress[i] = e.loaded;
dispatch(uploadComposeProgress(composeId, progress.reduce((a, v) => a + v, 0), e.total));

View File

@ -81,7 +81,7 @@ export class MastodonResponse extends Response {
z.string(),
z.object({ error: z.string(), description: z.string() }).array(),
).optional(),
});
}).passthrough();
}
}

View File

@ -1,3 +1,5 @@
import 'soapbox/polyfill/Promise.withResolvers.ts';
import { enableMapSet } from 'immer';
import { createRoot } from 'react-dom/client';

View File

@ -0,0 +1,14 @@
if (!Promise.withResolvers) {
Promise.withResolvers = function withResolvers<T>(): PromiseWithResolvers<T> {
let resolve: (value: T | PromiseLike<T>) => void;
let reject: (reason?: any) => void;
const promise = new this<T>((_resolve, _reject) => {
resolve = _resolve;
reject = _reject;
});
return { resolve: resolve!, reject: reject!, promise };
};
}

View File

@ -57,9 +57,13 @@ async function showAlertForError(networkError: HTTPError): Promise<void> {
return;
}
const data = await response.error();
if (data) {
return error(data.error);
try {
const data = await response.error();
if (data) {
return error(data.error);
}
} catch {
// fallthrough
}
const message = httpErrorMessages.find((httpError) => httpError.code === status)?.description;