Add autorefresh for document sets page

This commit is contained in:
Weves
2024-05-09 14:29:16 -07:00
committed by Chris Weaver
parent 683addc390
commit 957d3625c2
4 changed files with 6 additions and 4 deletions

View File

@@ -82,7 +82,7 @@ function Main({ documentSetId }: { documentSetId: number }) {
ccPairs={ccPairs}
userGroups={userGroups}
onClose={() => {
router.push("/admin/documents/sets");
router.push(`/admin/documents/sets?u=${Date.now()}`);
}}
setPopup={setPopup}
existingDocumentSet={documentSet}

View File

@@ -4,7 +4,9 @@ import useSWR, { mutate } from "swr";
export function useDocumentSets() {
const url = "/api/manage/admin/document-set";
const swrResponse = useSWR<DocumentSet[]>(url, errorHandlingFetcher);
const swrResponse = useSWR<DocumentSet[]>(url, errorHandlingFetcher, {
refreshInterval: 5000, // 5 seconds
});
return {
...swrResponse,

View File

@@ -50,7 +50,7 @@ function Main() {
ccPairs={ccPairs}
userGroups={userGroups}
onClose={() => {
router.push("/admin/documents/sets");
router.push(`/admin/documents/sets?u=${Date.now()}`);
}}
setPopup={setPopup}
/>

View File

@@ -42,7 +42,7 @@ const EditRow = ({ documentSet }: { documentSet: DocumentSet }) => {
return (
<div className="relative flex">
{isSyncingTooltipOpen && (
<div className="flex flex-nowrap absolute w-72 top-0 left-0 mt-8 border border-border bg-background px-3 py-2 rounded shadow-lg z-40">
<div className="flex flex-nowrap absolute w-64 top-0 left-0 mt-8 border border-border bg-background px-3 py-2 rounded shadow-lg break-words z-40">
<InfoIcon className="mt-1 flex flex-shrink-0 mr-2" /> Cannot update
while syncing! Wait for the sync to finish, then try again.
</div>