From 98445e999656f4001337a897e3547d630a2f33be Mon Sep 17 00:00:00 2001 From: Salihu Date: Fri, 31 Oct 2025 21:09:55 +0100 Subject: [PATCH] option to show more 'shared with me' documents --- .../Sidebar/components/GroupLink.tsx | 23 ++++++++++++++++++- .../Sidebar/components/SharedWithMe.tsx | 6 +++-- app/hooks/usePaginatedRequest.ts | 2 +- shared/i18n/locales/en_US/translation.json | 4 ++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/components/Sidebar/components/GroupLink.tsx b/app/components/Sidebar/components/GroupLink.tsx index 93884e02c4..be9bc2bcbf 100644 --- a/app/components/Sidebar/components/GroupLink.tsx +++ b/app/components/Sidebar/components/GroupLink.tsx @@ -8,19 +8,32 @@ import Relative from "./Relative"; import SharedWithMeLink from "./SharedWithMeLink"; import SidebarContext, { groupSidebarContext } from "./SidebarContext"; import SidebarLink from "./SidebarLink"; +import { RequestResponse } from "~/hooks/usePaginatedRequest"; +import GroupMembership from "~/models/GroupMembership"; +import { t } from "i18next"; +import { toast } from "sonner"; type Props = { /** The group to render */ group: Group; + /** The response from the group memberships request */ + response: RequestResponse; }; -const GroupLink: React.FC = ({ group }) => { +const GroupLink: React.FC = ({ group, response }) => { const locationSidebarContext = useLocationSidebarContext(); const sidebarContext = groupSidebarContext(group.id); + const { loading, next, end, error } = response; const [expanded, setExpanded] = React.useState( locationSidebarContext === sidebarContext ); + React.useEffect(() => { + if (error) { + toast.error(t("Could not load shared documents")); + } + }, [error, t]); + const handleDisclosureClick = React.useCallback((ev) => { ev?.preventDefault(); setExpanded((e) => !e); @@ -50,6 +63,14 @@ const GroupLink: React.FC = ({ group }) => { depth={1} /> ))} + {!end && ( + + )} diff --git a/app/components/Sidebar/components/SharedWithMe.tsx b/app/components/Sidebar/components/SharedWithMe.tsx index e9fddab908..79044ad8d0 100644 --- a/app/components/Sidebar/components/SharedWithMe.tsx +++ b/app/components/Sidebar/components/SharedWithMe.tsx @@ -30,7 +30,9 @@ function SharedWithMe() { const history = useHistory(); const locationSidebarContext = useLocationSidebarContext(); - usePaginatedRequest(groupMemberships.fetchAll); + const gmResponse = usePaginatedRequest( + groupMemberships.fetchAll + ); const { loading, next, end, error, page } = usePaginatedRequest(userMemberships.fetchPage, { @@ -108,7 +110,7 @@ function SharedWithMe() {
{user.groupsWithDocumentMemberships.map((group) => ( - + ))} {reorderProps.isDragging && ( diff --git a/app/hooks/usePaginatedRequest.ts b/app/hooks/usePaginatedRequest.ts index bc86f67fa7..dc742313aa 100644 --- a/app/hooks/usePaginatedRequest.ts +++ b/app/hooks/usePaginatedRequest.ts @@ -3,7 +3,7 @@ import { useState, useEffect, useCallback } from "react"; import { PaginationParams } from "~/types"; import useRequest from "./useRequest"; -type RequestResponse = { +export type RequestResponse = { /** The return value of the paginated request function. */ data: T[] | undefined; /** The request error, if any. */ diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 5ed92f4ce5..383042a200 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -427,11 +427,11 @@ "Expand": "Expand", "Document not supported – try Markdown, Plain text, HTML, or Word": "Document not supported – try Markdown, Plain text, HTML, or Word", "Import files": "Import files", + "Could not load shared documents": "Could not load shared documents", + "Show more": "Show more", "Go back": "Go back", "Go forward": "Go forward", - "Could not load shared documents": "Could not load shared documents", "Shared with me": "Shared with me", - "Show more": "Show more", "Link options": "Link options", "Could not load starred documents": "Could not load starred documents", "Starred": "Starred",