⚡️⚡️⚡️ 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(mobile): add links to tags directly without having to re-edit them
daniel31x135d3b4beb484f
diff --git a/apps/mobile/app/(tabs)/collections/[id].tsx b/apps/mobile/app/(tabs)/collections/[id].tsxindex acdf10ff..e351f8f2 100644--- a/apps/mobile/app/(tabs)/collections/[id].tsx+++ b/apps/mobile/app/(tabs)/collections/[id].tsx@@ -1,5 +1,9 @@import { useLinks } from "@linkwarden/router/links";-import { View, Platform } from "react-native";+import { View, Platform, TouchableOpacity } from "react-native";+import { Plus } from "lucide-react-native";+import { SheetManager } from "react-native-actions-sheet";+import { useColorScheme } from "nativewind";+import { rawTheme, ThemeName } from "@/lib/colors";import useAuthStore from "@/store/auth";import { useLocalSearchParams, useNavigation } from "expo-router";import React, { useEffect } from "react";@@ -25,6 +29,7 @@ export default function LinksScreen() {const collections = useCollections(auth);const navigation = useNavigation();+ const { colorScheme } = useColorScheme();const isIOS26Plus =Platform.OS === "ios" && parseInt(Platform.Version, 10) >= 26;@@ -34,18 +39,34 @@ export default function LinksScreen() {(e) => e.id === Number(id))[0];- if (activeCollection?.name)- navigation?.setOptions?.({- headerTitle: activeCollection?.name,- headerSearchBarOptions: {- placeholder: `Search ${activeCollection.name}`,- ...(isIOS26Plus && {- allowToolbarIntegration: false,- placement: "integratedButton",- }),- },- });- }, [navigation]);+ navigation?.setOptions?.({+ ...(activeCollection?.name+ ? {+ headerTitle: activeCollection.name,+ headerSearchBarOptions: {+ placeholder: `Search ${activeCollection.name}`,+ ...(isIOS26Plus && {+ allowToolbarIntegration: false,+ placement: "integratedButton",+ }),+ },+ }+ : {}),+ headerRight: () => (+ <TouchableOpacity+ onPress={() =>+ SheetManager.show("add-link-sheet", {+ payload: {+ collection: { id: Number(id), name: activeCollection?.name },+ },+ })+ }+ >+ <Plus size={21} color={rawTheme[colorScheme as ThemeName].primary} />+ </TouchableOpacity>+ ),+ });+ }, [navigation, collections.data, id, colorScheme]);return (<Viewdiff --git a/apps/mobile/app/(tabs)/dashboard/[section].tsx b/apps/mobile/app/(tabs)/dashboard/[section].tsxindex d118a1d5..b4be49c8 100644--- a/apps/mobile/app/(tabs)/dashboard/[section].tsx+++ b/apps/mobile/app/(tabs)/dashboard/[section].tsx@@ -1,5 +1,9 @@import { useLinks } from "@linkwarden/router/links";-import { View, Platform } from "react-native";+import { View, Platform, TouchableOpacity } from "react-native";+import { Plus } from "lucide-react-native";+import { SheetManager } from "react-native-actions-sheet";+import { useColorScheme } from "nativewind";+import { rawTheme, ThemeName } from "@/lib/colors";import useAuthStore from "@/store/auth";import { useLocalSearchParams, useNavigation } from "expo-router";import React, { useEffect, useMemo } from "react";@@ -16,6 +20,7 @@ export default function LinksScreen() {const navigation = useNavigation();const collections = useCollections(auth);+ const { colorScheme } = useColorScheme();const isIOS26Plus =Platform.OS === "ios" && parseInt(Platform.Version, 10) >= 26;@@ -43,8 +48,35 @@ export default function LinksScreen() {placement: "integratedButton",}),},+ headerRight:+ section === "pinned-links"+ ? undefined+ : () => (+ <TouchableOpacity+ onPress={() =>+ SheetManager.show(+ "add-link-sheet",+ section === "collection" && collectionId+ ? {+ payload: {+ collection: {+ id: Number(collectionId),+ name: title,+ },+ },+ }+ : undefined+ )+ }+ >+ <Plus+ size={21}+ color={rawTheme[colorScheme as ThemeName].primary}+ />+ </TouchableOpacity>+ ),});- }, [title, navigation]);+ }, [title, navigation, section, collectionId, colorScheme]);const { links, data } = useLinks({diff --git a/apps/mobile/app/(tabs)/tags/[id].tsx b/apps/mobile/app/(tabs)/tags/[id].tsxindex d4f9c9d8..f74bdc8c 100644--- a/apps/mobile/app/(tabs)/tags/[id].tsx+++ b/apps/mobile/app/(tabs)/tags/[id].tsx@@ -1,5 +1,9 @@import { useLinks } from "@linkwarden/router/links";-import { View, Platform } from "react-native";+import { View, Platform, TouchableOpacity } from "react-native";+import { Plus } from "lucide-react-native";+import { SheetManager } from "react-native-actions-sheet";+import { useColorScheme } from "nativewind";+import { rawTheme, ThemeName } from "@/lib/colors";import useAuthStore from "@/store/auth";import { useLocalSearchParams, useNavigation } from "expo-router";import React, { useEffect } from "react";@@ -28,22 +32,39 @@ export default function LinksScreen() {const tag = useTag(tagId, auth);const navigation = useNavigation();+ const { colorScheme } = useColorScheme();const isIOS26Plus =Platform.OS === "ios" && parseInt(Platform.Version, 10) >= 26;useEffect(() => {- if (tag.data?.name)- navigation?.setOptions?.({- headerTitle: tag.data.name,- headerSearchBarOptions: {- placeholder: `Search ${tag.data.name}`,- ...(isIOS26Plus && {- allowToolbarIntegration: false,- placement: "integratedButton",- }),- },- });- }, [navigation, tag.data?.name, isIOS26Plus]);+ navigation?.setOptions?.({+ ...(tag.data?.name+ ? {+ headerTitle: tag.data.name,+ headerSearchBarOptions: {+ placeholder: `Search ${tag.data.name}`,+ ...(isIOS26Plus && {+ allowToolbarIntegration: false,+ placement: "integratedButton",+ }),+ },+ }+ : {}),+ headerRight: () => (+ <TouchableOpacity+ onPress={() =>+ SheetManager.show("add-link-sheet", {+ payload: {+ tag: tagId != null ? { id: tagId, name: tag.data?.name } : {},+ },+ })+ }+ >+ <Plus size={21} color={rawTheme[colorScheme as ThemeName].primary} />+ </TouchableOpacity>+ ),+ });+ }, [navigation, tag.data?.name, tagId, isIOS26Plus, colorScheme]);return (<Viewdiff --git a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx b/apps/mobile/components/ActionSheets/AddLinkSheet.tsxindex 34ffcec1..d0b91d38 100644--- a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx+++ b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx@@ -1,6 +1,10 @@import { Alert, Text, View } from "react-native";import { useRef, useState } from "react";-import ActionSheet, { ActionSheetRef } from "react-native-actions-sheet";+import ActionSheet, {+ ActionSheetRef,+ SheetProps,+} from "react-native-actions-sheet";+import { Folder, Tag } from "lucide-react-native";import Input from "@/components/ui/Input";import { Button } from "@/components/ui/Button";import { useAddLink } from "@linkwarden/router/links";@@ -10,12 +14,16 @@ import { useColorScheme } from "nativewind";import { useSafeAreaInsets } from "react-native-safe-area-context";import SheetHeader from "./SheetHeader";-export default function AddLinkSheet() {+export default function AddLinkSheet(props: SheetProps<"add-link-sheet">) {const actionSheetRef = useRef<ActionSheetRef>(null);const { auth } = useAuthStore();const addLink = useAddLink({ auth, Alert });const [link, setLink] = useState("");const { colorScheme } = useColorScheme();+ const theme = rawTheme[colorScheme as ThemeName];++ const collection = props.payload?.collection;+ const tag = props.payload?.tag;const insets = useSafeAreaInsets();@@ -50,9 +58,48 @@ export default function AddLinkSheet() {onChangeText={setLink}/>+ {collection?.name || tag?.name ? (+ <View className="mb-4 flex-row items-center gap-2">+ {collection?.name ? (+ <View className="flex-row items-center gap-1.5 rounded-full bg-base-100 px-3 py-1.5">+ <Folder size={14} color={theme.primary} />+ <Text className="text-sm text-base-content">+ {collection.name}+ </Text>+ </View>+ ) : null}+ {tag?.name ? (+ <View className="flex-row items-center gap-1.5 rounded-full bg-base-100 px-3 py-1.5">+ <Tag size={14} color={theme.primary} />+ <Text className="text-sm text-base-content">{tag.name}</Text>+ </View>+ ) : null}+ </View>+ ) : null}+<ButtononPress={() => {- addLink.mutate({ url: link });+ addLink.mutate({+ url: link,+ ...(collection?.id != null || collection?.name+ ? {+ collection: {+ ...(collection.id != null ? { id: collection.id } : {}),+ ...(collection.name ? { name: collection.name } : {}),+ },+ }+ : {}),+ ...(tag?.name+ ? {+ tags: [+ {+ name: tag.name,+ ...(tag.id != null ? { id: tag.id } : {}),+ },+ ],+ }+ : {}),+ });actionSheetRef.current?.hide();setLink("");diff --git a/apps/mobile/components/ActionSheets/Sheets.tsx b/apps/mobile/components/ActionSheets/Sheets.tsxindex c6008ad2..d2252a59 100644--- a/apps/mobile/components/ActionSheets/Sheets.tsx+++ b/apps/mobile/components/ActionSheets/Sheets.tsx@@ -42,7 +42,12 @@ declare module "react-native-actions-sheet" {"login-sheet": SheetDefinition;"sign-up-sheet": SheetDefinition;"self-hosted-server-sheet": SheetDefinition;- "add-link-sheet": SheetDefinition;+ "add-link-sheet": SheetDefinition<{+ payload: {+ collection?: { id?: number; name?: string };+ tag?: { id?: number; name?: string };+ };+ }>;"link-details-sheet": SheetDefinition<{payload: {link: LinkIncludingShortenedCollectionAndTags;