A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
mobile: Add support for sharing text to the app
MohamedBassema80869cee9e8
diff --git a/packages/mobile/app.json b/packages/mobile/app.jsonindex 56773b57..96eb93a0 100644--- a/packages/mobile/app.json+++ b/packages/mobile/app.json@@ -38,7 +38,8 @@"NSExtensionActivationSupportsWebURLWithMaxCount": 1,"NSExtensionActivationSupportsWebPageWithMaxCount": 0,"NSExtensionActivationSupportsImageWithMaxCount": 0,- "NSExtensionActivationSupportsMovieWithMaxCount": 0+ "NSExtensionActivationSupportsMovieWithMaxCount": 0,+ "NSExtensionActivationSupportsText": true}}],diff --git a/packages/mobile/app/+not-found.tsx b/packages/mobile/app/+not-found.tsxnew file mode 100644index 00000000..466505b6--- /dev/null+++ b/packages/mobile/app/+not-found.tsx@@ -0,0 +1,6 @@+import { View } from "react-native";++// This is kinda important given that the sharing modal always resolve to an unknown route+export default function NotFound() {+ return <View />;+}diff --git a/packages/mobile/app/sharing.tsx b/packages/mobile/app/sharing.tsxindex 41c3212e..59c6fc25 100644--- a/packages/mobile/app/sharing.tsx+++ b/packages/mobile/app/sharing.tsx@@ -2,6 +2,7 @@ import { Link, useLocalSearchParams, useRouter } from "expo-router";import { ShareIntent } from "expo-share-intent";import { useEffect, useMemo, useState } from "react";import { View, Text } from "react-native";+import { z } from "zod";import { api } from "@/lib/trpc";@@ -27,7 +28,13 @@ function SaveBookmark({ setMode }: { setMode: (mode: Mode) => void }) {useEffect(() => {if (!isPending && shareIntent?.text) {- mutate({ type: "link", url: shareIntent.text });+ const val = z.string().url();+ if (val.safeParse(shareIntent.text).success) {+ // This is a URL, else treated as text+ mutate({ type: "link", url: shareIntent.text });+ } else {+ mutate({ type: "text", text: shareIntent.text });+ }}}, []);diff --git a/packages/mobile/package.json b/packages/mobile/package.jsonindex 37cc5ee4..9a9198c7 100644--- a/packages/mobile/package.json+++ b/packages/mobile/package.json@@ -35,7 +35,8 @@"react-native-screens": "~3.29.0","react-native-svg": "^15.1.0","tailwind-merge": "^2.2.1",- "use-debounce": "^10.0.0"+ "use-debounce": "^10.0.0",+ "zod": "^3.22.4"},"devDependencies": {"@babel/core": "^7.20.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 99194c39..835ad5f5 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -193,6 +193,9 @@ importers:packages/mobile:dependencies:+ '@hoarder/trpc':+ specifier: 0.1.0+ version: link:../trpc'@tanstack/react-query':specifier: ^5.24.8version: 5.24.8([email protected])@@ -268,6 +271,9 @@ importers:use-debounce:specifier: ^10.0.0version: 10.0.0([email protected])+ zod:+ specifier: ^3.22.4+ version: 3.22.4devDependencies:'@babel/core':specifier: ^7.20.0