Skip to content

Commit

Permalink
[Raycast Notification] Added success and failure notification types (#…
Browse files Browse the repository at this point in the history
…13958)

* feat(raycast-notification): added success and failure notification types

closes #13957

* Removed metadata not showing Raycast

* Update CHANGELOG.md and optimise images

---------

Co-authored-by: Per Nielsen Tikær <per@raycast.com>
Co-authored-by: raycastbot <bot@raycast.com>
  • Loading branch information
3 people committed Aug 20, 2024
1 parent d3dae34 commit 688169c
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 18 deletions.
7 changes: 5 additions & 2 deletions extensions/raycast-notification/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Raycast Notification Changelog

## Added icons and screenshots - 2024-08-08
## [Improvements] - 2024-08-20

## [Initial Version] - 2024-08-04
- Moved screenshots to metadata folder and used raycast colors for the command icon.
- Supported success and failure notification types with Toast API.

## [Initial Version] - 2024-08-04
15 changes: 11 additions & 4 deletions extensions/raycast-notification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ The HUD notifications of Raycast look super nice! Don't you wish you could use t

Well, this extension makes it easy to display Raycast notifications via a quicklink, making the beautiful Raycast interface accessible to other applications or scripts.

Use it from the terminal with `open -g "raycast://extensions/maxnyby/raycast-notification/index?launchType=background&arguments=%7B%22title%22%3A%22Notification%20Text%22%7D"`.
Make sure to url_encode the notificationtext, and of course to validate your input text before using it on the command line.
Use it from the terminal like:

![Interface example](assets/interface.png)
![Notification example](assets/notification.png)
```shell
open -g "raycast://extensions/maxnyby/raycast-notification/index?launchType=background&arguments=%7B%22title%22%3A%22Notification%20Text%22%7D"
```
```shell
open -g "raycast://extensions/maxnyby/raycast-notification/index?arguments=%7B%22title%22%3A%22Notification%20Text%22%2C%22type%22%3A%22success%22%7D"
```

> [!IMPORTANT]
> Make sure to url_encode the notificationtext, and of course to validate your input text before using it on the command line.
> Also, success and failure notification types are not supported in background mode.
Binary file modified extensions/raycast-notification/assets/command-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions extensions/raycast-notification/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions extensions/raycast-notification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "This extension makes it easy to display Raycast notifications via a quicklink, making the Raycast interface accessible to other applications or scripts",
"icon": "command-icon.png",
"author": "maxnyby",
"contributors": ["stelo"],
"categories": [
"Developer Tools"
],
Expand All @@ -21,6 +22,26 @@
"placeholder": "Title",
"type": "text",
"required": true
},
{
"name": "type",
"type": "dropdown",
"placeholder": "Type",
"required": false,
"data": [
{
"title": "Standard",
"value": "standard"
},
{
"title": "Success",
"value": "success"
},
{
"title": "Failure",
"value": "failure"
}
]
}
]
}
Expand All @@ -30,8 +51,8 @@
},
"devDependencies": {
"@raycast/eslint-config": "^1.0.8",
"@types/node": "20.8.10",
"@types/react": "18.3.3",
"@types/node": "^22.2.0",
"@types/react": "^18.3.3",
"eslint": "^8.57.0",
"prettier": "^3.2.5",
"typescript": "^5.4.5"
Expand Down
29 changes: 25 additions & 4 deletions extensions/raycast-notification/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import { showHUD, LaunchProps } from "@raycast/api";
import { closeMainWindow, LaunchProps, LaunchType, showHUD, showToast, Toast } from "@raycast/api";

export default async function main(props: LaunchProps<{ arguments: { title: string } }>) {
const { title } = props.arguments;
await showHUD(title);
export default async function main(props: LaunchProps<{ arguments: Arguments.Index }>) {
const {
arguments: { title, type },
launchType,
} = props;

let notificationType = type ?? "standard";
if (launchType === LaunchType.UserInitiated) {
await closeMainWindow();
} else {
// Toast API is not available when command is launched in the background.
notificationType = "standard";
}

switch (notificationType) {
case "success":
await showToast(Toast.Style.Success, title);
break;
case "failure":
await showToast(Toast.Style.Failure, title);
break;
default:
await showHUD(title);
}
}

0 comments on commit 688169c

Please sign in to comment.