-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add save to Readwise Reader integration to Hacker News extension (#16749
) * Update hacker-news extension - Add format script - Remove force unwrap and unused imports - Lint - Add publish script - Cache saved URLs and show an accessory - Fix import - Add documentation - Only show the save to readwise reader option if the token is set - Extract readwise logic to new file - Add action to save article to readwise reader - Automated add to contributors - Initial commit * Add changelog entry * Remove unnecessary explicit Preferences type * Restore preferences after merge conflict * Update CHANGELOG.md * Update preferences.ts * Refresh the save icon in the list on save action * Move UI updates to frontpage, for better separation of concerns * Make getReadwiseToken optional and handle undefined * Simplify: check local state only to check if URL is saved * Handle errors from caching operations * Set max cache size with FIFO policy * Linting * Update CHANGELOG.md and optimise images --------- Co-authored-by: Per Nielsen Tikær <[email protected]> Co-authored-by: raycastbot <[email protected]>
- Loading branch information
1 parent
945bd99
commit 83e2a36
Showing
7 changed files
with
384 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getPreferenceValues } from "@raycast/api"; | ||
|
||
/** | ||
* Checks if a Readwise API token is configured in preferences. | ||
* | ||
* @returns true if the token exists and is not empty, false otherwise | ||
*/ | ||
export function hasReadwiseToken(): boolean { | ||
try { | ||
const preferences = getPreferenceValues<Preferences>(); | ||
return !!preferences.readwiseToken; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Gets the Readwise API token from preferences. | ||
* | ||
* @returns The configured Readwise API token, or undefined if not configured | ||
*/ | ||
export function getReadwiseToken(): string | undefined { | ||
try { | ||
const preferences = getPreferenceValues<Preferences>(); | ||
return preferences.readwiseToken || undefined; | ||
} catch { | ||
return undefined; | ||
} | ||
} |
Oops, something went wrong.