Skip to content

Commit

Permalink
Fix AI chat using window.location.href for page URL
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
poltak committed Jun 24, 2024
1 parent 290366f commit 6856b1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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',
Expand All @@ -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) => {
Expand Down

0 comments on commit 6856b1b

Please sign in to comment.