diff --git a/frontend/src/components/card-content-file/CardContentFile.tsx b/frontend/src/components/card-content-file/CardContentFile.tsx index c51c0b00d..8a1ab3d69 100644 --- a/frontend/src/components/card-content-file/CardContentFile.tsx +++ b/frontend/src/components/card-content-file/CardContentFile.tsx @@ -1,4 +1,4 @@ -import { FC, useEffect } from "react"; +import { FC } from "react"; import { filesize } from "filesize"; @@ -9,18 +9,12 @@ import { PDFUploadViewer } from "../PdfUploadViewer/PdfUploadViewer"; import { PreviewContentImage } from "../preview-content-image/PreviewContentImage"; import { FILE_EXTENSION } from "~/core/enums/file-extension.enum"; import { ThemeBreakpoint } from "~/core/enums/theme-breakpoints.enum"; -import { useEntcoreBehaviours } from "~/hooks/useEntcoreBehaviours"; import { useFileExtensionDescription } from "~/hooks/useFileExtensionDescription"; import { useBoard } from "~/providers/BoardProvider"; import { useCanEditDocumentQuery } from "~/services/api/magnetoWorkspace.service"; export const CardContentFile: FC = ({ card }) => { const { documents, displayModals, hasEditRights } = useBoard(); - const { behaviours, isLoading } = useEntcoreBehaviours(); - - const initLool = async () => { - await behaviours.applicationsBehaviours["lool"].init(); - }; const cardDocument = documents.find((doc) => doc._id === card.resourceId); const extensionText = useFileExtensionDescription(card.metadata.extension); @@ -29,10 +23,6 @@ export const CardContentFile: FC = ({ card }) => { ); const size = filesize(card.metadata.size); - useEffect(() => { - initLool(); - }, [isLoading]); - const isOfficePdf = () => { const ext = [ FILE_EXTENSION.DOC, diff --git a/frontend/src/providers/BoardProvider/index.tsx b/frontend/src/providers/BoardProvider/index.tsx index efcddfc0c..762411b58 100644 --- a/frontend/src/providers/BoardProvider/index.tsx +++ b/frontend/src/providers/BoardProvider/index.tsx @@ -26,6 +26,7 @@ import { Board, IBoardItemResponse } from "~/models/board.model"; import { Card } from "~/models/card.model"; import { useGetBoardDataQuery } from "~/services/api/boardData.service"; import { useGetDocumentsQuery } from "~/services/api/workspace.service"; +import { useEntcoreBehaviours } from "~/hooks/useEntcoreBehaviours"; const BoardContext = createContext(null); @@ -47,6 +48,15 @@ export const BoardProvider: FC = ({ children }) => { const { id = "" } = useParams(); const { data: boardData, isLoading, isFetching } = useGetBoardDataQuery(id); const { data: documentsData } = useGetDocumentsQuery("stub"); + const { behaviours, isLoading: isLoadingBehaviours } = useEntcoreBehaviours(); + + const initLool = async () => { + await behaviours.applicationsBehaviours["lool"].init(); + }; + + useEffect(() => { + initLool(); + }, [isLoadingBehaviours]); const [boardRights, setBoardRights] = useState = ({ children }) => { cleanActiveCard, openActiveCardAction, closeActiveCardAction, + behaviours, }), [ board, @@ -166,6 +177,7 @@ export const BoardProvider: FC = ({ children }) => { isFileDragging, activeCard, isModalDuplicate, + behaviours, ], ); diff --git a/frontend/src/providers/BoardProvider/types.ts b/frontend/src/providers/BoardProvider/types.ts index f63d44938..81ecfc313 100644 --- a/frontend/src/providers/BoardProvider/types.ts +++ b/frontend/src/providers/BoardProvider/types.ts @@ -35,6 +35,7 @@ export type BoardContextType = { cleanActiveCard: () => void; openActiveCardAction: (card: Card, actionType: BOARD_MODAL_TYPE) => void; closeActiveCardAction: (actionType: BOARD_MODAL_TYPE) => void; + behaviours: any; }; export type Section = {