From a67d7c0dec1af87a6643891b0393bb015261a200 Mon Sep 17 00:00:00 2001 From: krsntn Date: Wed, 20 Nov 2024 23:21:55 +0800 Subject: [PATCH] Update google-maps-search extension - add preferredOrigin - Initial commit --- extensions/google-maps-search/CHANGELOG.md | 6 +++++ extensions/google-maps-search/package.json | 25 ++++++++++++++++++- .../google-maps-search/src/travelTo.tsx | 11 ++------ .../google-maps-search/src/utils/types.ts | 10 ++++++++ 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/extensions/google-maps-search/CHANGELOG.md b/extensions/google-maps-search/CHANGELOG.md index 915bc150d60cf..9688921e92c51 100644 --- a/extensions/google-maps-search/CHANGELOG.md +++ b/extensions/google-maps-search/CHANGELOG.md @@ -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 diff --git a/extensions/google-maps-search/package.json b/extensions/google-maps-search/package.json index bdfbc5914dcf9..bbd7c44a6a5db 100644 --- a/extensions/google-maps-search/package.json +++ b/extensions/google-maps-search/package.json @@ -11,7 +11,8 @@ "contributors": [ "lin", "chrismessina", - "klaussner" + "klaussner", + "krsntn" ], "keywords": [ "directions", @@ -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", diff --git a/extensions/google-maps-search/src/travelTo.tsx b/extensions/google-maps-search/src/travelTo.tsx index e1a06dd4059f1..07f3a2c302509 100644 --- a/extensions/google-maps-search/src/travelTo.tsx +++ b/extensions/google-maps-search/src/travelTo.tsx @@ -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(); // State variables - const [origin, setOrigin] = useState(OriginOption.CurLoc); // Controls which origin option is selected + const [origin, setOrigin] = useState(preferences.preferredOrigin); // Controls which origin option is selected const [originAddress, setOriginAddress] = useState(""); // Stores the origin address const [destination, setDestination] = useState(""); // Stores the destination address const [mode, setMode] = useState(preferences.preferredMode); // Stores the selected transport mode diff --git a/extensions/google-maps-search/src/utils/types.ts b/extensions/google-maps-search/src/utils/types.ts index c0b23f88ac4f8..ce5154de898a6 100644 --- a/extensions/google-maps-search/src/utils/types.ts +++ b/extensions/google-maps-search/src/utils/types.ts @@ -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; }