Skip to content

Commit 791efb6

Browse files
authored
add review suggestions
1 parent f9d4d10 commit 791efb6

File tree

3 files changed

+114
-29
lines changed

3 files changed

+114
-29
lines changed

extensions/at-profile/package-lock.json

+103-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/at-profile/package.json

+2-21
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,9 @@
8989
"description": "Quickly open a profile on a social site"
9090
}
9191
],
92-
"ai": {
93-
"evals": [
94-
{
95-
"name": "open_profile",
96-
"description": "Open a social media profile",
97-
"examples": [
98-
{
99-
"input": "Open raycast on GitHub",
100-
"output": {
101-
"tool": "open",
102-
"args": {
103-
"profile": "raycast",
104-
"site": "github"
105-
}
106-
}
107-
}
108-
]
109-
}
110-
]
111-
},
11292
"dependencies": {
113-
"@raycast/api": "^1.80.0"
93+
"@raycast/api": "^1.80.0",
94+
"@raycast/utils": "^1.19.1"
11495
},
11596
"devDependencies": {
11697
"@raycast/eslint-config": "^1.0.8",

extensions/at-profile/src/tools/open.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { open } from "@raycast/api";
22
import { getAllSites } from "../sites";
3+
import { showFailureToast } from "@raycast/utils";
34

45
type Input = {
56
/**
@@ -34,16 +35,17 @@ type Input = {
3435

3536
const tool = async (input: Input) => {
3637
const { profile, site } = input;
37-
3838
const allSites = await getAllSites();
39-
const enabledSites = allSites.filter((s) => s.value === site);
40-
const selectedSite = enabledSites.find((s) => s.value === site);
39+
const selectedSite = allSites.find((s) => s.value === site);
4140
if (!selectedSite) {
42-
throw new Error(`Site "${site}" not found or not enabled`);
41+
showFailureToast(`Site "${site}" not found or not enabled`, { title: "Failed to find site" });
42+
return;
4343
}
4444
const url = selectedSite.urlTemplate.replace("{profile}", profile);
45-
46-
await open(url);
45+
try {
46+
await open(url);
47+
} catch (error) {
48+
showFailureToast(`Failed to open ${site} profile: ${profile}`, { title: "Failed to open URL" });
49+
}
4750
};
48-
4951
export default tool;

0 commit comments

Comments
 (0)