-
Notifications
You must be signed in to change notification settings - Fork 6k
Update owl extension #27277
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
Merged
Merged
Update owl extension #27277
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9b2a3f3
Update owl extension
gohadar a0305aa
Added changelog
gohadar 9d3f36c
Added default owls and option to delete multiple owls
gohadar 1bea764
Update owl extension
gohadar 348f064
Update CHANGELOG.md and add platforms field
raycastbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| import { Action, Alert, confirmAlert, Icon } from "@raycast/api"; | ||
| import { useCachedStorage } from "../hooks/storage"; | ||
| import { OWLMapping } from "../types/owl"; | ||
| import { StorageKey } from "../types/storage"; | ||
|
|
||
| export function ClearAllOWLsAction() { | ||
| const [, setOWLs] = useCachedStorage<OWLMapping>(StorageKey.OWLS, {}); | ||
|
|
||
| return ( | ||
| <Action | ||
| title={"Clear Owls"} | ||
| style={Action.Style.Destructive} | ||
| icon={Icon.Trash} | ||
| shortcut={{ | ||
| modifiers: ["ctrl", "shift"], | ||
| key: "x", | ||
| }} | ||
| onAction={async () => { | ||
| if ( | ||
| await confirmAlert({ | ||
| title: "Are you sure?", | ||
| message: `Are you sure you want to clear all owls?`, | ||
| primaryAction: { | ||
| title: "Clear", | ||
| style: Alert.ActionStyle.Destructive, | ||
| }, | ||
| }) | ||
| ) { | ||
| setOWLs({}); | ||
| } | ||
| }} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or 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,36 @@ | ||
| import { Action, Alert, confirmAlert, Icon, Keyboard } from "@raycast/api"; | ||
| import { useCachedStorage } from "../hooks/storage"; | ||
| import { OWLMapping } from "../types/owl"; | ||
| import { StorageKey } from "../types/storage"; | ||
|
|
||
| export function DeleteAllOWLsAction(props: Readonly<{ language: string }>) { | ||
| const { language } = props; | ||
| const [, setOWLs] = useCachedStorage<OWLMapping>(StorageKey.OWLS, {}); | ||
|
|
||
| return ( | ||
| <Action | ||
| title={"Delete Owls"} | ||
| style={Action.Style.Destructive} | ||
| icon={Icon.Trash} | ||
| shortcut={Keyboard.Shortcut.Common.Remove} | ||
| onAction={async () => { | ||
| if ( | ||
| await confirmAlert({ | ||
| title: "Are you sure?", | ||
| message: `Are you sure you want to delete all owls of ${language}?`, | ||
| primaryAction: { | ||
| title: "Delete", | ||
| style: Alert.ActionStyle.Destructive, | ||
| }, | ||
| }) | ||
| ) { | ||
| setOWLs((previousState) => { | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| const { [language]: _, ...rest } = previousState; | ||
| return rest; | ||
| }); | ||
|
gohadar marked this conversation as resolved.
|
||
| } | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
This file contains hidden or 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,39 @@ | ||
| import { Action, Icon } from "@raycast/api"; | ||
| import { useKeyboards } from "../hooks/keyboards"; | ||
| import { useLanguages } from "../hooks/languages"; | ||
| import { useCachedStorage } from "../hooks/storage"; | ||
| import { OWLMapping } from "../types/owl"; | ||
| import { StorageKey } from "../types/storage"; | ||
| import { loadDefaultOWLs } from "../utils/loadDefaultOWLs"; | ||
|
|
||
| export function ResetToDefaultOWLAction( | ||
| props: Readonly< | ||
| Omit<Action.Props, "title" | "onAction"> & { | ||
| base?: string; | ||
| } | ||
| >, | ||
| ) { | ||
| const { keyboards } = useKeyboards(); | ||
| const { value: languages } = useLanguages(); | ||
| const [, setOWLs] = useCachedStorage<OWLMapping>(StorageKey.OWLS, {}); | ||
|
|
||
| return ( | ||
| <Action | ||
| title={"Reset to Default"} | ||
| style={Action.Style.Destructive} | ||
| icon={Icon.RotateAntiClockwise} | ||
| shortcut={{ | ||
| modifiers: ["cmd", "shift"], | ||
| key: "r", | ||
| }} | ||
| {...props} | ||
| onAction={async () => { | ||
| await loadDefaultOWLs({ | ||
| keyboards, | ||
| languages, | ||
| setOWLs, | ||
| }); | ||
| }} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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,44 @@ | ||
| import { useEffect } from "react"; | ||
| import { OWLMapping } from "../types/owl"; | ||
| import { StorageKey } from "../types/storage"; | ||
| import { loadDefaultOWLs } from "../utils/loadDefaultOWLs"; | ||
| import { useKeyboards } from "./keyboards"; | ||
| import { useLanguages } from "./languages"; | ||
| import { useCachedStorage } from "./storage"; | ||
|
|
||
| export type UseInitializeOWLs = { | ||
| isInitialized: boolean; | ||
| reinitialize: () => void; | ||
| }; | ||
|
|
||
| export function useInitializeOWLs( | ||
| { showAlert = false }: { showAlert: boolean } = { showAlert: false }, | ||
| ): UseInitializeOWLs { | ||
| const [, setOWLs] = useCachedStorage<OWLMapping>(StorageKey.OWLS, {}); | ||
| const [isInit, setIsInit] = useCachedStorage<boolean>(StorageKey.INIT, false); | ||
|
|
||
| const { keyboards } = useKeyboards(); | ||
| const { value: languages } = useLanguages(); | ||
|
|
||
| useEffect(() => { | ||
| if (keyboards.length === 0 || languages.length === 0 || isInit) { | ||
| return; | ||
| } | ||
|
|
||
| loadDefaultOWLs({ | ||
| keyboards, | ||
| languages, | ||
| setOWLs, | ||
| showAlert, | ||
| }).then(() => { | ||
| setIsInit(true); | ||
| }); | ||
| }, [isInit, keyboards, languages]); | ||
|
|
||
| return { | ||
| isInitialized: isInit, | ||
| reinitialize: () => { | ||
| setIsInit(false); | ||
| }, | ||
| }; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,57 @@ | ||
| import { Alert, confirmAlert } from "@raycast/api"; | ||
| import { randomUUID } from "node:crypto"; | ||
| import { OWL, OWLMapping } from "../types/owl"; | ||
| import { UseOWLs } from "./owl"; | ||
|
|
||
| export async function loadDefaultOWLs({ | ||
| languages, | ||
| keyboards, | ||
| setOWLs, | ||
| showAlert = true, | ||
| }: { | ||
| languages: string[]; | ||
| keyboards: string[]; | ||
| setOWLs: UseOWLs["setOWLs"]; | ||
| showAlert?: boolean; | ||
| }): Promise<boolean> { | ||
| const defaultMapping: OWLMapping = Object.fromEntries( | ||
| languages.map((language) => { | ||
| return [ | ||
| language, | ||
| languages | ||
| .flatMap((destinationLanguage) => { | ||
| return keyboards.filter((keyboard) => keyboard === destinationLanguage && keyboard !== language); | ||
| }) | ||
| .map( | ||
| (keyboard): OWL => ({ | ||
| id: randomUUID(), | ||
| from: language, | ||
| to: keyboard, | ||
| history: [], | ||
| }), | ||
| ), | ||
| ]; | ||
| }), | ||
| ); | ||
|
|
||
| if (showAlert) { | ||
| const shouldLoadDefault = await confirmAlert({ | ||
| title: "Are you sure?", | ||
| message: `Are you sure you want to reset the OWLs to the default mapping?\nThis will remove all existing OWLs | ||
| and add all permutations of your existing languages.`, | ||
| primaryAction: { | ||
| title: "Reset", | ||
| style: Alert.ActionStyle.Destructive, | ||
| }, | ||
| }); | ||
|
|
||
| // The user has been prompted and choose not to load defaults. | ||
| if (!shouldLoadDefault) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| setOWLs(defaultMapping); | ||
|
|
||
| return true; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{PR_MERGE_DATE}is a template token that should be replaced with the actual merge date before the PR is merged.Prompt To Fix With AI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pernielsentikaer, should I update this manually or is this part of the CI/CD? I remember it updating automatically when the merge is done but I'm not quite sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greptileai that's NOT correct, why do you say that? You should know that {PR_MERGE_DATE} is the right thing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged —
{PR_MERGE_DATE}is the standard Raycast convention and gets automatically populated at merge time. My original comment was incorrect; no changes needed here.Tip: You can give me more context with .greptile/rules so I get this right next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greptileai, so you already know this from your knowledge base, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes — rule
799af734in my knowledge base explicitly states that{PR_MERGE_DATE}should be left as-is, as it's the standard Raycast convention populated automatically at merge time. My original comment was wrong despite having that context.