From c5c71ba9507f1c739773cf2677c53f83d29300bc Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
Date: Sun, 23 Nov 2025 12:25:56 +0000
Subject: feat(mobile): proper handling for shared list permissions (#2165)

* feat(mobile): Restrict bookmark editing in shared lists

Apply the same ownership-based restrictions that exist in the web app
to the mobile app. Users can now only edit, delete, and manage their
own bookmarks, even when viewing them in shared lists.

Changes:
- BottomActions: Hide edit actions (lists, tags, info, delete) for non-owners
- BookmarkCard: Hide favorite button and action menu for non-owners
- Info page: Make title, notes, tags, and lists read-only for non-owners
- NotePreview: Hide "Edit Notes" button for non-owners

All restrictions are based on comparing the current user ID (from useWhoAmI)
with the bookmark's userId field.

* some fixes

* make tags non clickable for collaborators

* add leave list

---------

Co-authored-by: Claude <noreply@anthropic.com>
---
 apps/mobile/components/bookmarks/NotePreview.tsx | 33 ++++++++++++++----------
 1 file changed, 20 insertions(+), 13 deletions(-)

(limited to 'apps/mobile/components/bookmarks/NotePreview.tsx')

diff --git a/apps/mobile/components/bookmarks/NotePreview.tsx b/apps/mobile/components/bookmarks/NotePreview.tsx
index d529d56e..0283d179 100644
--- a/apps/mobile/components/bookmarks/NotePreview.tsx
+++ b/apps/mobile/components/bookmarks/NotePreview.tsx
@@ -10,9 +10,14 @@ import { Text } from "../ui/Text";
 interface NotePreviewProps {
   note: string;
   bookmarkId: string;
+  readOnly?: boolean;
 }
 
-export function NotePreview({ note, bookmarkId }: NotePreviewProps) {
+export function NotePreview({
+  note,
+  bookmarkId,
+  readOnly = false,
+}: NotePreviewProps) {
   const [isModalVisible, setIsModalVisible] = useState(false);
   const { colorScheme } = useColorScheme();
   const iconColor = colorScheme === "dark" ? "#9ca3af" : "#6b7280";
@@ -63,18 +68,20 @@ export function NotePreview({ note, bookmarkId }: NotePreviewProps) {
             </ScrollView>
 
             {/* Action Button */}
-            <View className="flex flex-row justify-end border-t border-border pt-4">
-              <Button
-                variant="secondary"
-                onPress={() => {
-                  setIsModalVisible(false);
-                  router.push(`/dashboard/bookmarks/${bookmarkId}/info`);
-                }}
-              >
-                <Text className="text-sm">Edit Notes</Text>
-                <ExternalLink size={14} color={modalIconColor} />
-              </Button>
-            </View>
+            {!readOnly && (
+              <View className="flex flex-row justify-end border-t border-border pt-4">
+                <Button
+                  variant="secondary"
+                  onPress={() => {
+                    setIsModalVisible(false);
+                    router.push(`/dashboard/bookmarks/${bookmarkId}/info`);
+                  }}
+                >
+                  <Text className="text-sm">Edit Notes</Text>
+                  <ExternalLink size={14} color={modalIconColor} />
+                </Button>
+              </View>
+            )}
           </View>
         </View>
       </Modal>
-- 
cgit v1.2.3-70-g09d2

