mirror of
https://github.com/arc53/DocsGPT
synced 2024-11-03 23:15:37 +00:00
small change
This commit is contained in:
parent
91df648767
commit
355d6e3cf2
@ -41,32 +41,39 @@ export default function APIKeyModal({
|
||||
|
||||
function handleCancel() {
|
||||
async function getRecentDocs() {
|
||||
const recentDocs = await getLocalRecentDocs();
|
||||
if (recentDocs) {
|
||||
setLocalSelectedDocs(recentDocs);
|
||||
const response = await getLocalRecentDocs();
|
||||
console.log('response');
|
||||
|
||||
if (response) {
|
||||
const parsedResponse = JSON.parse(response) as Doc;
|
||||
setLocalSelectedDocs(parsedResponse);
|
||||
}
|
||||
}
|
||||
|
||||
getRecentDocs();
|
||||
console.log('cancel');
|
||||
setIsError(false);
|
||||
setModalState('INACTIVE');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
async function getRecentDocs() {
|
||||
const response = await getLocalRecentDocs();
|
||||
|
||||
if (response) {
|
||||
const parsedResponse = JSON.parse(response) as Doc;
|
||||
|
||||
dispatch(setSelectedDocs(parsedResponse));
|
||||
setLocalSelectedDocs(parsedResponse);
|
||||
setModalState('INACTIVE');
|
||||
}
|
||||
}
|
||||
|
||||
async function requestDocs() {
|
||||
const data = await getDocs();
|
||||
dispatch(setSourceDocs(data));
|
||||
}
|
||||
|
||||
async function getRecentDocs() {
|
||||
const recentDocs = await getLocalRecentDocs();
|
||||
if (recentDocs) {
|
||||
dispatch(setSelectedDocs(recentDocs));
|
||||
setLocalSelectedDocs(recentDocs);
|
||||
setModalState('INACTIVE');
|
||||
}
|
||||
}
|
||||
|
||||
getRecentDocs();
|
||||
requestDocs();
|
||||
}, []);
|
||||
|
@ -33,23 +33,17 @@ export async function getDocs(): Promise<Doc[] | null> {
|
||||
export async function getLocalApiKey(): Promise<string | null> {
|
||||
try {
|
||||
const key = localStorage.getItem('DocsGPTApiKey');
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
return null;
|
||||
return key;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getLocalRecentDocs(): Promise<Doc | null> {
|
||||
export async function getLocalRecentDocs(): Promise<string | null> {
|
||||
try {
|
||||
const doc = localStorage.getItem('DocsGPTRecentDocs');
|
||||
if (doc) {
|
||||
return JSON.parse(doc);
|
||||
}
|
||||
return null;
|
||||
return doc;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user