-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IP Geolocation] Update Copy IP command
- Loading branch information
Showing
24 changed files
with
743 additions
and
802 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
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
16 changes: 7 additions & 9 deletions
16
extensions/ip-geolocation/src/components/action-open-command-preferences.tsx
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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { Action, ActionPanel, Icon, openCommandPreferences } from "@raycast/api"; | ||
import { Action, Icon, openCommandPreferences } from "@raycast/api"; | ||
|
||
export function ActionOpenCommandPreferences() { | ||
return ( | ||
<ActionPanel.Section> | ||
<Action | ||
icon={Icon.Gear} | ||
title="Open Extension Preferences" | ||
shortcut={{ modifiers: ["shift", "cmd"], key: "," }} | ||
onAction={openCommandPreferences} | ||
/> | ||
</ActionPanel.Section> | ||
<Action | ||
icon={Icon.Gear} | ||
title="Configure Command" | ||
shortcut={{ modifiers: ["shift", "cmd"], key: "," }} | ||
onAction={openCommandPreferences} | ||
/> | ||
); | ||
} |
16 changes: 7 additions & 9 deletions
16
extensions/ip-geolocation/src/components/action-open-extension-preferences.tsx
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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { Action, ActionPanel, Icon, openExtensionPreferences } from "@raycast/api"; | ||
import { Action, Icon, openExtensionPreferences } from "@raycast/api"; | ||
|
||
export function ActionOpenExtensionPreferences() { | ||
return ( | ||
<ActionPanel.Section> | ||
<Action | ||
icon={Icon.Gear} | ||
title="Open Extension Preferences" | ||
shortcut={{ modifiers: ["shift", "cmd"], key: "," }} | ||
onAction={openExtensionPreferences} | ||
/> | ||
</ActionPanel.Section> | ||
<Action | ||
icon={Icon.Gear} | ||
title="Configure Extension" | ||
shortcut={{ modifiers: ["shift", "cmd"], key: "." }} | ||
onAction={openExtensionPreferences} | ||
/> | ||
); | ||
} |
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,62 @@ | ||
import { getIPV4Address, getIPV6Address, isEmpty } from "./utils/common-utils"; | ||
import { | ||
captureException, | ||
Clipboard, | ||
closeMainWindow, | ||
environment, | ||
LaunchProps, | ||
LaunchType, | ||
showHUD, | ||
updateCommandMetadata, | ||
} from "@raycast/api"; | ||
import { publicIpv4, publicIpv6 } from "public-ip"; | ||
import { CopyIpArguments, IpType, IpVersion } from "./types/preferences"; | ||
|
||
export default async (props: LaunchProps<{ arguments: CopyIpArguments }>) => { | ||
const { ipType, ipVersion } = props.arguments; | ||
const ipTypeString = ipType === IpType.PUBLIC ? IpType.PUBLIC : IpType.LOCAL; | ||
const ipVersionString = ipVersion === IpVersion.IPV6 ? IpVersion.IPV6 : IpVersion.IPV4; | ||
try { | ||
await closeMainWindow(); | ||
let ip = ""; | ||
if (ipTypeString === IpType.LOCAL) { | ||
let ip_; | ||
if (ipVersionString === IpVersion.IPV4) { | ||
ip_ = getIPV4Address(); | ||
} else { | ||
ip_ = getIPV6Address(); | ||
} | ||
ip = ip_ ? ip_ : ""; | ||
} else { | ||
let ip_; | ||
if (ipVersionString === IpVersion.IPV4) { | ||
ip_ = await publicIpv4({ onlyHttps: true }) | ||
.then((ip) => ip) | ||
.catch(() => ""); | ||
} else { | ||
ip_ = await publicIpv6({ onlyHttps: true }) | ||
.then((ip) => ip) | ||
.catch(() => ""); | ||
} | ||
ip = ip_ ? ip_ : ""; | ||
} | ||
|
||
if (environment.launchType === LaunchType.UserInitiated) { | ||
if (!isEmpty(ip)) { | ||
await Clipboard.copy(`${ip}`); | ||
await showHUD(`🅿️ ${ipTypeString} ${ipVersionString} ${ip}`); | ||
} else { | ||
await showHUD(`🚨 Failed to get ${ipTypeString} ${ipVersionString} `); | ||
} | ||
} | ||
|
||
if (ip) { | ||
await updateCommandMetadata({ subtitle: ` ${ipTypeString} ${ipVersionString} ${ip}` }); | ||
} else { | ||
await updateCommandMetadata({ subtitle: `IP Geolocation` }); | ||
} | ||
} catch (e) { | ||
captureException(e); | ||
console.error(e); | ||
} | ||
}; |
This file was deleted.
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
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