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

Update google-maps-search extension #15453

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions extensions/google-maps-search/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Google Maps Search Changelog

## [Added preferred starting location] - 2024-11-20

### Added

- Added the ability to set a preferred starting location.

## [Travel mode fixes and improvements] - 2024-08-21

### Changed
Expand Down
25 changes: 24 additions & 1 deletion extensions/google-maps-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"contributors": [
"lin",
"chrismessina",
"klaussner"
"klaussner",
"krsntn"
],
"keywords": [
"directions",
Expand Down Expand Up @@ -95,6 +96,28 @@
}
]
},
{
"name": "preferredOrigin",
"title": "Preferred Starting Location",
"description": "Select your preferred starting location.",
"type": "dropdown",
"required": true,
"default": "curloc",
"data": [
{
"title": "Current Location",
"value": "curloc"
},
{
"title": "Home",
"value": "home"
},
{
"title": "Custom",
"value": "custom"
}
]
},
{
"name": "useSelected",
"title": "Use selected text or clipboard to fill destination",
Expand Down
11 changes: 2 additions & 9 deletions extensions/google-maps-search/src/travelTo.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import { Action, ActionPanel, Form, getPreferenceValues, Icon, popToRoot } from "@raycast/api";
import { useEffect, useState, useCallback } from "react";
import { fetchItemInput } from "./utils/input";
import { Preferences, TransportType } from "./utils/types";
import { Preferences, TransportType, OriginOption } from "./utils/types";
import { makeDirectionsURL } from "./utils/url";

// Enum for origin options in the form
enum OriginOption {
CurLoc = "curloc",
Home = "home",
Custom = "custom",
}

export default function Command() {
// Get user preferences
const preferences = getPreferenceValues<Preferences>();

// State variables
const [origin, setOrigin] = useState<OriginOption>(OriginOption.CurLoc); // Controls which origin option is selected
const [origin, setOrigin] = useState<OriginOption>(preferences.preferredOrigin); // Controls which origin option is selected
const [originAddress, setOriginAddress] = useState<string>(""); // Stores the origin address
const [destination, setDestination] = useState<string>(""); // Stores the destination address
const [mode, setMode] = useState<string>(preferences.preferredMode); // Stores the selected transport mode
Expand Down
10 changes: 10 additions & 0 deletions extensions/google-maps-search/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ export enum TransportType {
Walking = "walking",
}

/**
* Enum for origin options in the form
*/
export enum OriginOption {
CurLoc = "curloc",
Home = "home",
Custom = "custom",
}

/**
* Corresponds to the preferences defined in package.json.
*/
export interface Preferences {
homeAddress: string;
preferredMode: string;
preferredOrigin: OriginOption;
useSelected: boolean;
saveSearchHistory: boolean;
}
Loading