From 71aa24a5d2ec5601574c030b7407a356e6ad71d1 Mon Sep 17 00:00:00 2001 From: Huey Date: Wed, 16 Jun 2021 17:53:29 +0800 Subject: [PATCH] store lawnet search query pre-redirect --- package.json | 2 +- src/Popup/ExternalLinks.tsx | 13 ++++++++++++- src/pages/Guide/Guide.tsx | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bd4216a..e0174d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clerkent", - "version": "2.7.2", + "version": "2.7.3", "private": true, "description": "quick search for international caselaw and legislation", "repository": "https://github.com/lacuna-technologies/clerkent.git", diff --git a/src/Popup/ExternalLinks.tsx b/src/Popup/ExternalLinks.tsx index 7353440..c955c89 100644 --- a/src/Popup/ExternalLinks.tsx +++ b/src/Popup/ExternalLinks.tsx @@ -1,10 +1,12 @@ -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState , useCallback } from 'react' import type Law from '../types/Law' import Constants from '../utils/Constants' import OptionsStorage from '../utils/OptionsStorage' import type { OptionsSettings, InstitutionalLogin } from '../utils/OptionsStorage' import './ExternalLinks.scss' +import SearcherStorage from '../ContentScript/Searcher/SearcherStorage' + interface Props { jurisdiction: Law.JursidictionCode type: Law.Type @@ -31,6 +33,14 @@ const ExternalLinks: React.FC = ({ }) => { const [institution, setInstitution] = useState(OptionsStorage.defaultOptions.OPTIONS_INSTITUTIONAL_LOGIN) + const onLawnetClick = useCallback(() => { + // this is necessary because the NUS and SMU proxies don't pass query params + // and the redirect occurs before content scripts have time to run + if([`NUS`, `SMU`].includes(institution)){ + SearcherStorage.storeLawNetQuery(query) + } + }, [query, institution]) + useEffect(() => { (async () => { const institutionSelection = await OptionsStorage.institutionalLogin.get() as InstitutionalLogin @@ -67,6 +77,7 @@ const ExternalLinks: React.FC = ({ <> LawNet diff --git a/src/pages/Guide/Guide.tsx b/src/pages/Guide/Guide.tsx index afaa0cc..39aad33 100644 --- a/src/pages/Guide/Guide.tsx +++ b/src/pages/Guide/Guide.tsx @@ -33,6 +33,12 @@ const Guide = () => { ) : null } +

+ Tip: If you use an institutional login for proprietary databases (e.g. WestLaw or LawNet), you should set it on the  + Options page +  so Clerkent can redirect you to the appropriate login page. +

+

Once you've clicked the icon and found the Clerkent search box, you can close this tab.