From a614693dfa71dbed529ec186aea96b23bcebc1e3 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Fri, 16 Jan 2026 13:00:53 +0500 Subject: [PATCH] mobile: fix web clip does not include url & date clipped --- apps/mobile/app/share/share.tsx | 693 +++++++++++++++++--------------- 1 file changed, 360 insertions(+), 333 deletions(-) diff --git a/apps/mobile/app/share/share.tsx b/apps/mobile/app/share/share.tsx index 7fbd6aed2..9b5f6c942 100644 --- a/apps/mobile/app/share/share.tsx +++ b/apps/mobile/app/share/share.tsx @@ -23,6 +23,7 @@ import ShareExtension, { import { getPreviewData } from "@flyerhq/react-native-link-preview"; import { formatBytes, + getFormattedDate, isFeatureAvailable, useIsFeatureAvailable } from "@notesnook/common"; @@ -47,7 +48,6 @@ import { import RNFetchBlob from "react-native-blob-util"; import { SafeAreaProvider, - SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; @@ -70,14 +70,20 @@ import { Search } from "./search"; import { initDatabase, useShareStore } from "./store"; import { isTablet } from "react-native-device-info"; import { NotesnookModule } from "../utils/notesnook-module"; +import { DefaultAppStyles } from "../utils/styles"; const getLinkPreview = (url: string) => { return getPreviewData(url, 5000); }; -async function sanitizeHtml(site: string) { +async function sanitizeHtml(site: string, title?: string) { try { let html = await fetchHandle.current?.processUrl(site); - return html; + return ( + html + + "
" + + `

Clipped from ${title || site}

+

Date clipped ${getFormattedDate(Date.now())}

` + ); } catch (e) { return ""; } @@ -145,6 +151,7 @@ const ShareView = () => { const noteContent = useRef(undefined); const noteTitle = useRef(undefined); const [loading, setLoading] = useState(false); + const [loadingData, setLoadingData] = useState(true); const [loadingExtension, setLoadingExtension] = useState(true); const fullQualityImages = useIsFeatureAvailable("fullQualityImages"); const [rawData, setRawData] = useState<{ @@ -210,7 +217,6 @@ const ShareView = () => { }; const onLoad = useCallback(() => { - console.log(noteContent.current, "current..."); eSendEvent(eOnLoadNote + "shareEditor", { id: null, content: { @@ -226,6 +232,7 @@ const ShareView = () => { try { if (noteContent.current) { onLoad(); + setLoadingData(false); return; } defaultNote.content.data = undefined; @@ -242,6 +249,7 @@ const ShareView = () => { editorRef.current?.focus(); }, 300); } + setLoadingData(false); return; } @@ -298,7 +306,9 @@ const ShareView = () => { }); onLoad(); setNote({ ...note }); + setLoadingData(false); } catch (e) { + setLoadingData(false); console.error(e); } }, @@ -311,6 +321,7 @@ const ShareView = () => { await initDatabase(); setLoadingExtension(false); useShareStore.getState().restore(); + loadData(false); } catch (e) { DatabaseLogger.error(e); } @@ -389,7 +400,7 @@ const ShareView = () => { if (value === 2) { setLoadingPage(true); setTimeout(async () => { - let html = await sanitizeHtml(rawData?.value || ""); + let html = await sanitizeHtml(rawData?.value || "", note.title); noteContent.current = html || ""; setLoadingPage(false); onLoad(); @@ -503,391 +514,407 @@ const ShareView = () => { maxHeight: Platform.OS === "android" ? undefined : "100%" }} > - + {loadingData ? ( + + Loading clip... + + ) : ( + - {appendNoteId ? ( - - Save note - - ) : ( - { - noteTitle.current = value; - }} - defaultValue={noteTitle.current} - blurOnSubmit={false} - onSubmitEditing={() => { - editorRef.current?.focus(); - }} - /> - )} -