@@ -2,22 +2,22 @@ import { useCallback, useEffect, useRef, useState } from "react";
22import type { EditorRefApi , CollaborationState } from "@plane/editor" ;
33// plane editor
44import { convertBinaryDataToBase64String , getBinaryDataFromDocumentEditorHTMLString } from "@plane/editor" ;
5- // plane propel
6- import { setToast , TOAST_TYPE } from "@plane/propel/toast" ;
75// plane types
86import type { TDocumentPayload } from "@plane/types" ;
97// hooks
108import useAutoSave from "@/hooks/use-auto-save" ;
9+ import type { TPageInstance } from "@/store/pages/base-page" ;
1110
1211type TArgs = {
1312 editorRef : React . RefObject < EditorRefApi > ;
1413 fetchPageDescription : ( ) => Promise < ArrayBuffer > ;
1514 collaborationState : CollaborationState | null ;
1615 updatePageDescription : ( data : TDocumentPayload ) => Promise < void > ;
16+ page : TPageInstance ;
1717} ;
1818
1919export const usePageFallback = ( args : TArgs ) => {
20- const { editorRef, fetchPageDescription, collaborationState, updatePageDescription } = args ;
20+ const { editorRef, fetchPageDescription, collaborationState, updatePageDescription, page } = args ;
2121 const hasShownFallbackToast = useRef ( false ) ;
2222
2323 const [ isFetchingFallbackBinary , setIsFetchingFallbackBinary ] = useState ( false ) ;
@@ -32,12 +32,7 @@ export const usePageFallback = (args: TArgs) => {
3232
3333 // Show toast notification when fallback mechanism kicks in (only once)
3434 if ( ! hasShownFallbackToast . current ) {
35- // setToast({
36- // type: TOAST_TYPE.WARNING,
37- // title: "Connection lost",
38- // message: "Your changes are being saved using backup mechanism. ",
39- // });
40- console . log ( "Connection lost" ) ;
35+ console . warn ( "Websocket Connection lost, your changes are being saved using backup mechanism." ) ;
4136 hasShownFallbackToast . current = true ;
4237 }
4338
@@ -49,7 +44,11 @@ export const usePageFallback = (args: TArgs) => {
4944 if ( latestEncodedDescription && latestEncodedDescription . byteLength > 0 ) {
5045 latestDecodedDescription = new Uint8Array ( latestEncodedDescription ) ;
5146 } else {
52- latestDecodedDescription = getBinaryDataFromDocumentEditorHTMLString ( "<p></p>" ) ;
47+ const pageDescriptionHtml = page . description_html ;
48+ latestDecodedDescription = getBinaryDataFromDocumentEditorHTMLString (
49+ pageDescriptionHtml ?? "<p></p>" ,
50+ page . name
51+ ) ;
5352 }
5453
5554 editor . setProviderDocument ( latestDecodedDescription ) ;
@@ -64,15 +63,10 @@ export const usePageFallback = (args: TArgs) => {
6463 } ) ;
6564 } catch ( error : any ) {
6665 console . error ( error ) ;
67- // setToast({
68- // type: TOAST_TYPE.ERROR,
69- // title: "Error",
70- // message: `Failed to update description using backup mechanism, ${error?.message}`,
71- // });
7266 } finally {
7367 setIsFetchingFallbackBinary ( false ) ;
7468 }
75- } , [ editorRef , fetchPageDescription , hasConnectionFailed , updatePageDescription ] ) ;
69+ } , [ editorRef , fetchPageDescription , hasConnectionFailed , updatePageDescription , page . description_html , page . name ] ) ;
7670
7771 useEffect ( ( ) => {
7872 if ( hasConnectionFailed ) {
0 commit comments