removed async on local storage functions

pull/115/head
TaylorS15 1 year ago
parent fc239bb37e
commit 18b7402d56

@ -42,8 +42,8 @@ export default function APIKeyModal({
} }
useEffect(() => { useEffect(() => {
async function getApiKey() { function getApiKey() {
const localKey = await getLocalApiKey(); const localKey = getLocalApiKey();
if (localKey) { if (localKey) {
dispatch(setApiKey(localKey)); dispatch(setApiKey(localKey));
setKey(localKey); setKey(localKey);

@ -55,12 +55,11 @@ export default function APIKeyModal({
} }
useEffect(() => { useEffect(() => {
async function getRecentDocs() { function getRecentDocs() {
const response = await getLocalRecentDocs(); const response = getLocalRecentDocs();
if (response) { if (response) {
const parsedResponse = JSON.parse(response) as Doc; const parsedResponse = JSON.parse(response) as Doc;
dispatch(setSelectedDocs(parsedResponse)); dispatch(setSelectedDocs(parsedResponse));
setLocalSelectedDocs(parsedResponse); setLocalSelectedDocs(parsedResponse);
setModalState('INACTIVE'); setModalState('INACTIVE');

@ -30,38 +30,20 @@ export async function getDocs(): Promise<Doc[] | null> {
} }
} }
export async function getLocalApiKey(): Promise<string | null> { export function getLocalApiKey(): string | null {
try { const key = localStorage.getItem('DocsGPTApiKey');
const key = localStorage.getItem('DocsGPTApiKey'); return key;
return key;
} catch (error) {
console.log(error);
return null;
}
} }
export async function getLocalRecentDocs(): Promise<string | null> { export function getLocalRecentDocs(): string | null {
try { const doc = localStorage.getItem('DocsGPTRecentDocs');
const doc = localStorage.getItem('DocsGPTRecentDocs'); return doc;
return doc;
} catch (error) {
console.log(error);
return null;
}
} }
export async function setLocalApiKey(key: string): Promise<void> { export function setLocalApiKey(key: string): void {
try { localStorage.setItem('DocsGPTApiKey', key);
localStorage.setItem('DocsGPTApiKey', key);
} catch (error) {
console.log(error);
}
} }
export async function setLocalRecentDocs(doc: Doc): Promise<void> { export function setLocalRecentDocs(doc: Doc): void {
try { localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(doc));
localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(doc));
} catch (error) {
console.log(error);
}
} }

Loading…
Cancel
Save