Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

add preferred collection + edit links when sharing

daniel31x13cc37543324e7
diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index 4fae60bf..2ae7a9f1 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -2,7 +2,7 @@
"expo": {
"name": "Linkwarden",
"slug": "linkwarden",
- "version": "1.0.2",
+ "version": "1.1.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "linkwarden",
diff --git a/apps/mobile/app/(tabs)/settings/_layout.tsx b/apps/mobile/app/(tabs)/settings/_layout.tsx
index fd9f2026..b0115dfe 100644
--- a/apps/mobile/app/(tabs)/settings/_layout.tsx
+++ b/apps/mobile/app/(tabs)/settings/_layout.tsx
@@ -19,6 +19,7 @@ export default function Layout() {
headerLargeStyle: {
backgroundColor: rawTheme[colorScheme as ThemeName]["base-100"],
},
+ headerBackTitle: "Back",
headerStyle: {
backgroundColor:
Platform.OS === "ios"
@@ -28,6 +29,15 @@ export default function Layout() {
: "white",
},
}}
- />
+ >
+ <Stack.Screen name="index" />
+ <Stack.Screen
+ name="preferredCollection"
+ options={{
+ headerTitle: "Preferred Collection",
+ headerLargeTitle: false,
+ }}
+ />
+ </Stack>
);
}
diff --git a/apps/mobile/app/(tabs)/settings/index.tsx b/apps/mobile/app/(tabs)/settings/index.tsx
index 3f62ac8e..6c1cd7f6 100644
--- a/apps/mobile/app/(tabs)/settings/index.tsx
+++ b/apps/mobile/app/(tabs)/settings/index.tsx
@@ -16,7 +16,9 @@ import { useEffect, useState } from "react";
import {
AppWindowMac,
Check,
+ ChevronRight,
ExternalLink,
+ Folder,
LogOut,
Mail,
Moon,
@@ -25,6 +27,7 @@ import {
} from "lucide-react-native";
import useDataStore from "@/store/data";
import * as Clipboard from "expo-clipboard";
+import { useRouter } from "expo-router";
export default function SettingsScreen() {
const { signOut, auth } = useAuthStore();
@@ -40,6 +43,8 @@ export default function SettingsScreen() {
updateData({ theme: override });
}, [override]);
+ const router = useRouter();
+
return (
<View
style={styles.container}
@@ -196,6 +201,33 @@ export default function SettingsScreen() {
</View>
</View>
+ <View>
+ <Text className="mb-4 mx-4 text-neutral">Save Shared Links To</Text>
+ <View className="bg-base-200 rounded-xl flex-col">
+ <TouchableOpacity
+ className="flex-row gap-2 items-center justify-between py-3 px-4"
+ onPress={() => router.navigate("/settings/preferredCollection")}
+ >
+ <View className="flex-row items-center gap-2">
+ <Folder
+ size={20}
+ color={rawTheme[colorScheme as ThemeName].neutral}
+ />
+ <Text className="text-base-content">Preferred collection</Text>
+ </View>
+ <View className="flex-row items-center gap-2">
+ <Text numberOfLines={1} className="text-neutral max-w-[140px]">
+ {data.preferredCollection?.name || "None"}
+ </Text>
+ <ChevronRight
+ size={20}
+ color={rawTheme[colorScheme as ThemeName].neutral}
+ />
+ </View>
+ </TouchableOpacity>
+ </View>
+ </View>
+
<View>
<Text className="mb-4 mx-4 text-neutral">Contact Us</Text>
<View className="bg-base-200 rounded-xl flex-col">
diff --git a/apps/mobile/app/(tabs)/settings/preferredCollection.tsx b/apps/mobile/app/(tabs)/settings/preferredCollection.tsx
new file mode 100644
index 00000000..f6fad2d9
--- /dev/null
+++ b/apps/mobile/app/(tabs)/settings/preferredCollection.tsx
@@ -0,0 +1,99 @@
+import { View, Text, FlatList, TouchableOpacity } from "react-native";
+import React, { useCallback, useMemo, useState } from "react";
+import useAuthStore from "@/store/auth";
+import useDataStore from "@/store/data";
+import { useCollections } from "@linkwarden/router/collections";
+import { CollectionIncludingMembersAndLinkCount } from "@linkwarden/types";
+import Input from "@/components/ui/Input";
+import { Folder, Check } from "lucide-react-native";
+import { useColorScheme } from "nativewind";
+import { rawTheme, ThemeName } from "@/lib/colors";
+
+const PreferredCollectionScreen = () => {
+ const { auth } = useAuthStore();
+ const { data, updateData } = useDataStore();
+ const collections = useCollections(auth);
+ const { colorScheme } = useColorScheme();
+ const [searchQuery, setSearchQuery] = useState("");
+
+ const filteredCollections = useMemo(() => {
+ if (!collections.data) return [];
+ const q = searchQuery.trim().toLowerCase();
+ if (q === "") return collections.data;
+ return collections.data.filter((col) => col.name.toLowerCase().includes(q));
+ }, [collections.data, searchQuery]);
+
+ const renderCollection = useCallback(
+ ({
+ item: collection,
+ }: {
+ item: CollectionIncludingMembersAndLinkCount;
+ }) => {
+ const isSelected = data.preferredCollection?.id === collection.id;
+
+ return (
+ <TouchableOpacity
+ className="bg-base-200 rounded-lg px-4 py-3 mb-3 flex-row items-center justify-between"
+ onPress={() => updateData({ preferredCollection: collection })}
+ >
+ <View className="flex-row items-center gap-2 w-[70%]">
+ <Folder
+ size={20}
+ fill={collection.color || "gray"}
+ color={collection.color || "gray"}
+ />
+ <Text numberOfLines={1} className="text-base-content">
+ {collection.name}
+ </Text>
+ </View>
+ <View className="flex-row items-center gap-2">
+ {isSelected ? (
+ <Check
+ size={16}
+ color={rawTheme[colorScheme as ThemeName].primary}
+ />
+ ) : null}
+ <Text className="text-neutral">
+ {collection._count?.links ?? 0}
+ </Text>
+ </View>
+ </TouchableOpacity>
+ );
+ },
+ [colorScheme, data.preferredCollection?.id, updateData]
+ );
+
+ return (
+ <View className="flex-1 bg-base-100">
+ <FlatList
+ data={filteredCollections}
+ keyExtractor={(item) => item.id?.toString() || ""}
+ renderItem={renderCollection}
+ contentContainerStyle={{
+ paddingHorizontal: 20,
+ paddingTop: 20,
+ paddingBottom: 20,
+ }}
+ contentInsetAdjustmentBehavior="automatic"
+ ListHeaderComponent={
+ <Input
+ placeholder="Search collections"
+ className="mb-4 bg-base-200 h-10"
+ value={searchQuery}
+ onChangeText={setSearchQuery}
+ />
+ }
+ ListEmptyComponent={
+ <Text
+ style={{ textAlign: "center", marginTop: 20 }}
+ className="text-neutral"
+ >
+ No collections match “{searchQuery}”
+ </Text>
+ }
+ />
+ </View>
+ );
+};
+
+export default PreferredCollectionScreen;
diff --git a/apps/mobile/app/incoming.tsx b/apps/mobile/app/incoming.tsx
index fa41532e..12517ea5 100644
--- a/apps/mobile/app/incoming.tsx
+++ b/apps/mobile/app/incoming.tsx
@@ -1,11 +1,11 @@
-import React, { useEffect } from "react";
+import React, { useEffect, useState } from "react";
import {
SafeAreaView,
View,
Text,
- StyleSheet,
ActivityIndicator,
Alert,
+ TouchableOpacity,
} from "react-native";
import { Redirect, useRouter } from "expo-router";
import useAuthStore from "@/store/auth";
@@ -14,6 +14,8 @@ import { Check } from "lucide-react-native";
import { useAddLink } from "@linkwarden/router/links";
import { rawTheme, ThemeName } from "@/lib/colors";
import { useColorScheme } from "nativewind";
+import { SheetManager } from "react-native-actions-sheet";
+import { LinkIncludingShortenedCollectionAndTags } from "@linkwarden/types";
export default function IncomingScreen() {
const { auth } = useAuthStore();
@@ -21,13 +23,20 @@ export default function IncomingScreen() {
const { data, updateData } = useDataStore();
const addLink = useAddLink(auth);
const { colorScheme } = useColorScheme();
+ const [showSuccess, setShowSuccess] = useState(false);
+ const [link, setLink] = useState<LinkIncludingShortenedCollectionAndTags>();
useEffect(() => {
if (auth.status === "authenticated" && data.shareIntent.url)
addLink.mutate(
- { url: data.shareIntent.url },
{
- onSuccess: () => {
+ url: data.shareIntent.url,
+ collection: { id: data.preferredCollection?.id },
+ },
+ {
+ onSuccess: (e) => {
+ setLink(e as unknown as LinkIncludingShortenedCollectionAndTags);
+ setShowSuccess(true);
setTimeout(() => {
updateData({
shareIntent: {
@@ -36,7 +45,7 @@ export default function IncomingScreen() {
},
});
router.replace("/dashboard");
- }, 1000);
+ }, 1500);
},
onError: (error) => {
Alert.alert("Error", "There was an error adding the link.");
@@ -50,49 +59,39 @@ export default function IncomingScreen() {
return (
<SafeAreaView className="flex-1 bg-base-100">
- {data?.shareIntent.url ? (
- <View className="flex-1 items-center justify-center">
- <Check
- size={140}
- className="mb-3 text-base-content"
- color={rawTheme[colorScheme as ThemeName].primary}
- />
- <Text className="text-2xl font-semibold text-base-content">
- Link Saved!
- </Text>
- </View>
- ) : (
- <View className="flex-1 items-center justify-center">
- <ActivityIndicator size="large" />
- <Text className="mt-3 text-base text-base-content opacity-70">
- One sec… {String(data?.shareIntent.url)}
- </Text>
- </View>
- )}
+ <View className="flex-1 items-center justify-center">
+ {data?.shareIntent.url && showSuccess && link ? (
+ <>
+ <Check
+ size={140}
+ className="mb-3 text-base-content"
+ color={rawTheme[colorScheme as ThemeName].primary}
+ />
+ <Text className="text-2xl font-semibold text-base-content">
+ Link Saved!
+ </Text>
+ <TouchableOpacity
+ className="w-fit mx-auto mt-5"
+ onPress={() =>
+ SheetManager.show("edit-link-sheet", {
+ payload: {
+ link: link,
+ },
+ })
+ }
+ >
+ <Text className="text-neutral text-center w-fit">Edit Link</Text>
+ </TouchableOpacity>
+ </>
+ ) : (
+ <>
+ <ActivityIndicator size="large" />
+ <Text className="mt-3 text-base text-base-content opacity-70">
+ One sec…
+ </Text>
+ </>
+ )}
+ </View>
</SafeAreaView>
);
}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: "#fff",
- },
- center: {
- flex: 1,
- alignItems: "center",
- justifyContent: "center",
- },
- check: {
- marginBottom: 12,
- },
- title: {
- fontSize: 28,
- fontWeight: "600",
- },
- subtitle: {
- marginTop: 12,
- fontSize: 16,
- opacity: 0.7,
- },
-});
diff --git a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
index c45e80f3..caf0574e 100644
--- a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
+++ b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
@@ -23,7 +23,7 @@ export default function AddLinkSheet() {
ref={actionSheetRef}
gestureEnabled
indicatorStyle={{
- backgroundColor: rawTheme[colorScheme as ThemeName]["neutral-content"],
+ display: "none",
}}
containerStyle={{
backgroundColor: rawTheme[colorScheme as ThemeName]["base-200"],
@@ -31,6 +31,8 @@ export default function AddLinkSheet() {
safeAreaInsets={insets}
>
<View className="px-8 py-5">
+ <Text className="font-semibold text-lg mx-auto mb-5">New Link</Text>
+
<Input
placeholder="e.g. https://example.com"
className="mb-4 bg-base-100"
diff --git a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx b/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
index 36ebc576..cb5304ec 100644
--- a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
+++ b/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
@@ -1,4 +1,4 @@
-import { View, Text, Alert } from "react-native";
+import { View, Text, Alert, TouchableOpacity } from "react-native";
import { useCallback, useEffect, useMemo, useState } from "react";
import ActionSheet, {
FlatList,
@@ -20,7 +20,7 @@ import {
import { useCollections } from "@linkwarden/router/collections";
import { rawTheme, ThemeName } from "@/lib/colors";
import { useColorScheme } from "nativewind";
-import { Folder, ChevronRight, Check } from "lucide-react-native";
+import { Folder, ChevronRight, ChevronLeft, Check } from "lucide-react-native";
import useTmpStore from "@/store/tmp";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useTags } from "@linkwarden/router/tags";
@@ -47,6 +47,8 @@ const Main = (props: SheetProps<"edit-link-sheet">) => {
return (
<View className="px-8 py-5">
+ <Text className="font-semibold text-lg mx-auto mb-5">Edit Link</Text>
+
<Input
placeholder="Name"
className="mb-4 bg-base-100"
@@ -221,6 +223,20 @@ const Collections = () => {
return (
<View className="py-5 max-h-[80vh]">
+ <TouchableOpacity
+ className="flex-row items-center gap-1 top-6 left-8 absolute"
+ onPress={() => {
+ router?.popToTop();
+ router?.navigate("main", { link: currentLink });
+ }}
+ >
+ <ChevronLeft
+ size={18}
+ color={rawTheme[colorScheme as ThemeName]["primary"]}
+ />
+ <Text className="text-primary">Back</Text>
+ </TouchableOpacity>
+ <Text className="font-semibold text-lg mx-auto mb-5">Collection</Text>
<Input
placeholder="Search collections"
className="mb-4 bg-base-100 mx-8"
@@ -251,13 +267,11 @@ const Tags = () => {
const addLink = useAddLink(auth);
const [searchQuery, setSearchQuery] = useState("");
const router = useSheetRouter("edit-link-sheet");
- const { link: currentLink } = useSheetRouteParams<"edit-link-sheet", "tags">(
- "edit-link-sheet",
- "tags"
- );
const params = useSheetRouteParams("edit-link-sheet", "tags");
const tags = useTags(auth);
const { colorScheme } = useColorScheme();
+ const [updatedLink, setUpdatedLink] =
+ useState<LinkIncludingShortenedCollectionAndTags>(params.link);
const filteredTags = useMemo(() => {
if (!tags.data) return [];
@@ -269,20 +283,17 @@ const Tags = () => {
const renderItem = useCallback(
({ item: tag }: { item: TagIncludingLinkCount }) => {
const onSelect = () => {
- const isSelected = (currentLink?.tags || []).some(
+ const isSelected = (updatedLink?.tags || []).some(
(t) => t.id === tag.id
);
const nextTags = isSelected
- ? (currentLink?.tags || []).filter((t) => t.id !== tag.id)
- : [...(currentLink?.tags || []), tag];
+ ? (updatedLink?.tags || []).filter((t) => t.id !== tag.id)
+ : [...(updatedLink?.tags || []), tag];
- const updatedLink = {
- ...currentLink,
+ setUpdatedLink({
+ ...updatedLink,
tags: nextTags,
- };
-
- router?.popToTop();
- router?.navigate("main", { link: updatedLink });
+ });
};
return (
@@ -293,7 +304,7 @@ const Tags = () => {
</Text>
</View>
<View className="flex-row items-center gap-2">
- {params.link?.tags.find((e) => e.id === tag.id) && (
+ {updatedLink?.tags.find((e) => e.id === tag.id) && (
<Check
size={16}
color={rawTheme[colorScheme as ThemeName].primary}
@@ -309,6 +320,20 @@ const Tags = () => {
return (
<View className="py-5 max-h-[80vh]">
+ <TouchableOpacity
+ className="flex-row items-center gap-1 top-6 left-8 absolute"
+ onPress={() => {
+ router?.popToTop();
+ router?.navigate("main", { link: updatedLink });
+ }}
+ >
+ <ChevronLeft
+ size={18}
+ color={rawTheme[colorScheme as ThemeName]["primary"]}
+ />
+ <Text className="text-primary">Back</Text>
+ </TouchableOpacity>
+ <Text className="font-semibold text-lg mx-auto mb-5">Tags</Text>
<Input
placeholder="Search tags"
className="mb-4 bg-base-100 mx-8"
@@ -358,9 +383,8 @@ export default function EditLinkSheet() {
<ActionSheet
gestureEnabled
indicatorStyle={{
- backgroundColor: rawTheme[colorScheme as ThemeName]["neutral-content"],
+ display: "none",
}}
- enableRouterBackNavigation={true}
routes={routes}
initialRoute="main"
containerStyle={{
diff --git a/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx b/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx
index 3a65f54c..a07ac184 100644
--- a/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx
+++ b/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx
@@ -26,7 +26,7 @@ export default function NewCollectionSheet() {
ref={actionSheetRef}
gestureEnabled
indicatorStyle={{
- backgroundColor: rawTheme[colorScheme as ThemeName]["neutral-content"],
+ display: "none",
}}
containerStyle={{
backgroundColor: rawTheme[colorScheme as ThemeName]["base-200"],
@@ -34,6 +34,10 @@ export default function NewCollectionSheet() {
safeAreaInsets={insets}
>
<View className="px-8 py-5">
+ <Text className="font-semibold text-lg mx-auto mb-5">
+ New Collection
+ </Text>
+
<Input
placeholder="Name"
className="mb-4 bg-base-100"
diff --git a/apps/mobile/store/data.ts b/apps/mobile/store/data.ts
index c9ba3ac0..ed8c5cf4 100644
--- a/apps/mobile/store/data.ts
+++ b/apps/mobile/store/data.ts
@@ -17,6 +17,7 @@ const useDataStore = create<DataStore>((set, get) => ({
},
theme: "system",
preferredBrowser: "app",
+ preferredCollection: null,
},
setData: async () => {
const dataString = JSON.parse((await AsyncStorage.getItem("data")) || "{}");
diff --git a/packages/types/global.ts b/packages/types/global.ts
index c15c7202..afc62318 100644
--- a/packages/types/global.ts
+++ b/packages/types/global.ts
@@ -187,4 +187,5 @@ export interface MobileData {
};
theme: "light" | "dark" | "system";
preferredBrowser: "app" | "system";
+ preferredCollection: CollectionIncludingMembersAndLinkCount | null;
}