Skip to content

Commit

Permalink
Messages: Fix permission issue and quicklink improvements (#13503)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslombart committed Jul 16, 2024
1 parent d8c6597 commit ab33299
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 102 deletions.
5 changes: 5 additions & 0 deletions extensions/messages/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Messages Changelog

## [Improvements] - 2024-07-16

- **Messages Quicklinks:** Users can now create address quicklinks directly in the Messages app.
- **Permission Request:** The extension will now ask for permission to access your contacts. If permission is denied, a clear error message will be displayed.

## [Improvements] - 2024-07-03

- Added a preference allowing users to close Raycast when sending a message.
Expand Down
2 changes: 1 addition & 1 deletion extensions/messages/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Messages

Send quick messages.
Send quick messages from Raycast.
131 changes: 71 additions & 60 deletions extensions/messages/package-lock.json

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

14 changes: 7 additions & 7 deletions extensions/messages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
}
],
"dependencies": {
"@raycast/api": "^1.76.0",
"@raycast/utils": "^1.16.0"
"@raycast/api": "^1.78.1",
"@raycast/utils": "^1.16.2"
},
"devDependencies": {
"@raycast/eslint-config": "^1.0.8",
"@types/node": "20.11.6",
"@types/react": "18.2.48",
"eslint": "^8.56.0",
"prettier": "^3.2.4",
"typescript": "^5.3.3"
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"eslint": "^8.57.0",
"prettier": "^3.3.3",
"typescript": "^5.5.3"
},
"scripts": {
"build": "ray build -e dist",
Expand Down
48 changes: 37 additions & 11 deletions extensions/messages/src/send-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,25 @@ export default function Command({
launchContext: { contactId: string; address: string; text: string };
}>) {
const { shouldCloseMainWindow } = getPreferenceValues<{ shouldCloseMainWindow: boolean }>();
const { data: contacts, isLoading } = useCachedPromise(async () => {
const contacts = await fetchAllContacts();
return contacts as Contact[];
});
const { data: contacts, isLoading } = useCachedPromise(
async () => {
const contacts = await fetchAllContacts();
return contacts as Contact[];
},
[],
{
failureToastOptions: {
title: "Could not get contacts",
message: "Make sure you have granted Raycast access to your contacts.",
primaryAction: {
title: "Open System Preferences",
onAction() {
open("x-apple.systempreferences:com.apple.preference.security?Privacy_Contacts");
},
},
},
},
);

const { itemProps, handleSubmit, values, reset, focus } = useForm<Values>({
async onSubmit(values) {
Expand Down Expand Up @@ -133,13 +148,24 @@ export default function Command({
actions={
<ActionPanel>
<Action.SubmitForm icon={Icon.SpeechBubble} title="Send Message" onSubmit={handleSubmit} />
<Action.CreateQuicklink
title="Create Messages Quicklink"
quicklink={{
link: createDeeplink(values.contact, values.address, values.text),
name: `Send Message to ${contacts?.find((c) => c.id === values.contact)?.givenName}`,
}}
/>

<ActionPanel.Section>
<Action.CreateQuicklink
title="Create Messages Quicklink"
icon={{ fileIcon: "/System/Applications/Messages.app" }}
quicklink={{
link: `sms:${values.address}`,
name: `Send Message to ${contacts?.find((c) => c.id === values.contact)?.givenName}`,
}}
/>
<Action.CreateQuicklink
title="Create Raycast Quicklink"
quicklink={{
link: createDeeplink(values.contact, values.address, values.text),
name: `Send Message to ${contacts?.find((c) => c.id === values.contact)?.givenName}`,
}}
/>
</ActionPanel.Section>
</ActionPanel>
}
enableDrafts
Expand Down
Loading

0 comments on commit ab33299

Please sign in to comment.