Skip to content

Commit

Permalink
store lawnet search query pre-redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
hueyy committed Jun 16, 2021
1 parent c5aa26d commit 71aa24a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 12 additions & 1 deletion src/Popup/ExternalLinks.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -31,6 +33,14 @@ const ExternalLinks: React.FC<Props> = ({
}) => {
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
Expand Down Expand Up @@ -67,6 +77,7 @@ const ExternalLinks: React.FC<Props> = ({
<>
<a
href={getLawNetURL(institution, query)}
onClick={onLawnetClick}
target="_blank" rel="noreferrer"
>LawNet</a>
</>
Expand Down
6 changes: 6 additions & 0 deletions src/pages/Guide/Guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const Guide = () => {
) : null
}

<p>
<strong>Tip:&nbsp;</strong>If you use an institutional login for proprietary databases (e.g. WestLaw or LawNet), you should set it on the&nbsp;
<a href="/options.html">Options page</a>
&nbsp;so Clerkent can redirect you to the appropriate login page.
</p>

<p>
Once you've clicked the icon and found the Clerkent search box, you can close this tab.
</p>
Expand Down

0 comments on commit 71aa24a

Please sign in to comment.