From 6856b1bb6ed346835fc941b6b6497f54064cfcea Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Mon, 24 Jun 2024 11:37:47 +0700 Subject: [PATCH] Fix AI chat using window.location.href for page URL - This will not work in the dashboard as that will be a chrome ext URL. Instead the sidebar keeps track of the underlying page which it's open for's URL in `state.fullPageUrl`. Thus I've updated it to use that - In general window.location.href should be avoided --- external/@worldbrain/memex-common | 2 +- .../annotations-sidebar/components/AnnotationsSidebar.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/external/@worldbrain/memex-common b/external/@worldbrain/memex-common index 96a61568ee..8e477f6366 160000 --- a/external/@worldbrain/memex-common +++ b/external/@worldbrain/memex-common @@ -1 +1 @@ -Subproject commit 96a61568ee61f7f57054b55c3e809114aa4a683e +Subproject commit 8e477f6366faeb854460b86ac0798caf7729e20f diff --git a/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx b/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx index 392e47cd3f..49e5bf6381 100644 --- a/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx +++ b/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx @@ -582,8 +582,8 @@ export class AnnotationsSidebar extends React.Component< } async getLocalContent() { - let isPagePDF = window.location.href.includes('/pdfjs/viewer.html?') - let fullTextToProcess + let isPagePDF = this.props.fullPageUrl?.includes('/pdfjs/viewer.html?') + let fullTextToProcess: string if (isPagePDF) { const searchParams = new URLSearchParams(window.location.search) const filePath = searchParams.get('file') @@ -2729,7 +2729,7 @@ export class AnnotationsSidebar extends React.Component< while (!executed) { try { if ( - isUrlYTVideo(window.location.href) + isUrlYTVideo(this.props.fullPageUrl) ) { let video = document.getElementsByTagName( 'video', @@ -2754,7 +2754,7 @@ export class AnnotationsSidebar extends React.Component< } else { executed = this.props.events.emit( 'addPageUrlToEditor', - window.location.href, + this.props.fullPageUrl, null, false, (success) => {