mirror of
https://github.com/ByteAtATime/raycast-linux.git
synced 2025-08-30 18:57:25 +00:00
feat(toast): add showToast overload function
This commit updates the showToast function to support multiple calling signatures, allowing for both an options object and individual parameters for style, title, and message. The latter is not officially documented, but is present in the type definitions of @raycast/api.
This commit is contained in:
parent
e0f2889c0d
commit
3ad7c0ecbb
1 changed files with 25 additions and 2 deletions
|
@ -97,8 +97,31 @@ class ToastImpl implements api.Toast {
|
|||
}
|
||||
}
|
||||
|
||||
export async function showToast(options: api.Toast.Options): Promise<api.Toast> {
|
||||
export async function showToast(options: api.Toast.Options): Promise<api.Toast>;
|
||||
export async function showToast(
|
||||
style: api.Toast.Style,
|
||||
title: string,
|
||||
message?: string
|
||||
): Promise<api.Toast>;
|
||||
|
||||
export async function showToast(
|
||||
optionsOrStyle: api.Toast.Options | api.Toast.Style,
|
||||
title?: string,
|
||||
message?: string
|
||||
): Promise<api.Toast> {
|
||||
let options: api.Toast.Options;
|
||||
|
||||
if (typeof optionsOrStyle === 'object' && optionsOrStyle !== null) {
|
||||
options = optionsOrStyle;
|
||||
} else {
|
||||
options = {
|
||||
style: optionsOrStyle,
|
||||
title: title as string,
|
||||
message
|
||||
};
|
||||
}
|
||||
|
||||
const toast = new ToastImpl(options);
|
||||
toast._sendShowCommand();
|
||||
await toast.show();
|
||||
return toast;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue