⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
feat(extension): persist the state of the "more options" dropdown
daniel31x135d232f164f0f
diff --git a/apps/extension/src/@/components/BookmarkForm.tsx b/apps/extension/src/@/components/BookmarkForm.tsxindex 32422816..528d0d75 100644--- a/apps/extension/src/@/components/BookmarkForm.tsx+++ b/apps/extension/src/@/components/BookmarkForm.tsx@@ -17,7 +17,12 @@ import { Button } from "./ui/Button.tsx";import TagInput from "./TagInput.tsx";import CollectionInput from "./CollectionInput.tsx";import { Textarea } from "./ui/Textarea.tsx";-import { getCurrentTabInfo, updateBadge } from "../lib/utils.ts";+import {+ getCurrentTabInfo,+ getStorageItem,+ setStorageItem,+ updateBadge,+} from "../lib/utils.ts";import { useEffect, useMemo, useState } from "react";import { useInfiniteQuery, useMutation, useQuery } from "@tanstack/react-query";import { getConfig, isConfigured as getIsConfigured } from "../lib/config.ts";@@ -31,6 +36,10 @@ import { ExternalLink } from "lucide-react";import { Checkbox } from "./ui/CheckBox.tsx";import { Label } from "./ui/Label.tsx";+// The popup is torn down every time it loses focus, so remember whether the+// user had the extra options expanded and bring them back that way.+const MORE_OPTIONS_KEY = "lw_more_options_open";+const BookmarkForm = () => {const [openOptions, setOpenOptions] = useState<boolean>(false);const [openCollections, setOpenCollections] = useState<boolean>(false);@@ -59,6 +68,12 @@ const BookmarkForm = () => {form.setValue("image", s ? "png" : undefined);};+ const handleOptionsToggle = () => {+ const next = !openOptions;+ setOpenOptions(next);+ void setStorageItem(MORE_OPTIONS_KEY, next ? "true" : "false");+ };+const form = useForm<bookmarkFormValues>({resolver: zodResolver(bookmarkFormSchema),defaultValues: {@@ -122,6 +137,8 @@ const BookmarkForm = () => {useEffect(() => {const setTabInformation = async () => {+ setOpenOptions((await getStorageItem(MORE_OPTIONS_KEY)) === "true");+const t = await getCurrentTabInfo();const c = await getConfig();@@ -361,7 +378,7 @@ const BookmarkForm = () => {<Buttonvariant="ghost"type="button"- onClick={() => setOpenOptions((prevState) => !prevState)}+ onClick={handleOptionsToggle}>{openOptions ? "Hide" : "More"} Options</Button>diff --git a/apps/extension/src/pages/Background/index.ts b/apps/extension/src/pages/Background/index.tsindex 40ad3b49..66902228 100644--- a/apps/extension/src/pages/Background/index.ts+++ b/apps/extension/src/pages/Background/index.ts@@ -300,7 +300,7 @@ browser.runtime.onInstalled.addListener(async function () {});});-browser.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any) => {+browser.tabs.onUpdated.addListener(async (tabId, changeInfo) => {if (!changeInfo.url) return;try {await updateBadge(tabId, false);diff --git a/apps/extension/version.xcconfig b/apps/extension/version.xcconfigindex 3d2fb196..8c0a046c 100644--- a/apps/extension/version.xcconfig+++ b/apps/extension/version.xcconfig@@ -4,5 +4,5 @@// CURRENT_PROJECT_VERSION is preserved across builds and is yours to edit.// Raise it before every App Store Connect upload you archive locally; it// must always be higher than the last build Apple accepted.-MARKETING_VERSION = 1.5.5+MARKETING_VERSION = 1.5.6CURRENT_PROJECT_VERSION = 3