Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add later extension #12901

Merged
merged 9 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: use preferences api
  • Loading branch information
Ross249 committed Jun 21, 2024
commit d8f643b2a364f94a4fa979db9b2dae724a698751
69 changes: 62 additions & 7 deletions extensions/later/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,68 @@
"Productivity",
"Other"
],
"preferences": [
{
"name": "links_from",
"title": "Save Links From",
"type": "dropdown",
"description": "Choose your browser to save links from",
"required": true,
"default": "chrome",
"data": [
{
"title": "Google Chrome",
"value": "chrome"
},
{
"title": "Safari",
"value": "safari"
},
{
"title": "Firefox",
"value": "firefox"
},
{
"title": "Microsoft Edge",
"value": "edge"
},
{
"title": "Arc",
"value": "arc"
}
]
},
{
"name": "links_to",
"title": "Open Links On",
"type": "dropdown",
"description": "Choose your browser to open links on",
"required": true,
"default": "chrome",
"data": [
{
"title": "Google Chrome",
"value": "chrome"
},
{
"title": "Safari",
"value": "safari"
},
{
"title": "Firefox",
"value": "firefox"
},
{
"title": "Microsoft Edge",
"value": "edge"
},
{
"title": "Arc",
"value": "arc"
}
]
}
],
"license": "MIT",
"commands": [
{
Expand All @@ -31,13 +93,6 @@
"subtitle": "Read Later",
"description": "Added link manually",
"mode": "view"
},
{
"name": "preferences",
"title": "Preferences",
"subtitle": "Read Later",
"description": "Read Later Preferences",
"mode": "view"
}
],
"dependencies": {
Expand Down
8 changes: 5 additions & 3 deletions extensions/later/src/components/ItemActions.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { useCallback } from "react";
import { ListItem } from "../types/common";
import { Action, ActionPanel, Icon, LocalStorage } from "@raycast/api";
import { Action, ActionPanel, Icon, getPreferenceValues } from "@raycast/api";
import { open_link_handler } from "../utils/handler";
import { Browser } from "../common/config";
import { PreferenceValue } from "../types/validate";

const ItemActions: React.FC<ListItem> = (props) => {
const open_link_to_browser = useCallback(async () => {
const browser = (await LocalStorage.getItem("links_to")) ?? "chrome";
const open_link_to_browser = useCallback(() => {
const preferences = getPreferenceValues<PreferenceValue>();
const browser = preferences.links_to ?? "chrome";
const browser_name = Browser.find((item) => item.id === browser)?.name ?? "Google Chrome";
open_link_handler({ url: props.url, browser_name: browser_name });
}, []);
Expand Down
7 changes: 5 additions & 2 deletions extensions/later/src/later.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { LocalStorage, closeMainWindow, showToast } from "@raycast/api";
import { closeMainWindow, getPreferenceValues, showToast } from "@raycast/api";
import { Scripts, expression } from "./utils/scripts";
import { runAppleScript } from "run-applescript";
import { add_link_handler } from "./utils/handler";
import { splitter } from "./common/config";
import { PreferenceValue } from "./types/validate";

const later = async () => {
const regex = new RegExp(expression);
const preference = getPreferenceValues<PreferenceValue>();

await closeMainWindow();
try {
const browser = (await LocalStorage.getItem("links_from")) ?? "chrome";
const browser = preference.links_from ?? "chrome";

const script = Scripts[browser as keyof typeof Scripts];

Expand Down
66 changes: 0 additions & 66 deletions extensions/later/src/preferences.tsx

This file was deleted.