Skip to content

Commit

Permalink
Clenaup
Browse files Browse the repository at this point in the history
  • Loading branch information
emilkowalski committed Nov 10, 2023
1 parent eaf8ab1 commit 88c3c95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ class Observer {
return this.create({ ...data, type: 'loading', message });
};

promise = <ToastData>(
promise: PromiseT<ToastData & { ok?: boolean; status?: string }>,
data?: PromiseData<ToastData>,
) => {
promise = <ToastData>(promise: PromiseT<ToastData>, data?: PromiseData<ToastData>) => {
if (!data) {
// Nothing to show
return;
Expand All @@ -127,9 +124,12 @@ class Observer {
let shouldDismiss = id !== undefined;

p.then((response) => {
if (response.ok !== undefined && !response.ok) {
// TODO: Clean up TS here, response has incorrect type
// @ts-expect-error
if (response && typeof response.ok === 'boolean' && !response.ok) {
shouldDismiss = false;
const message =
// @ts-expect-error
typeof data.error === 'function' ? data.error(`HTTP error! status: ${response.status}`) : data.error;
this.create({ id, type: 'error', message });
} else if (data.success !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Types/Types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ toast.promise(promise, {
{
name: 'Custom',
snippet: `toast(<div>A custom toast with default styling</div>)`,
action: () => toast(<div>A custom toast with default styling</div>),
action: () => toast(<div>A custom toast with default styling</div>, { duration: 1000000 }),
},
];

0 comments on commit 88c3c95

Please sign in to comment.