mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +00:00
removed async on local storage functions
This commit is contained in:
@@ -42,8 +42,8 @@ export default function APIKeyModal({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
async function getApiKey() {
|
||||
const localKey = await getLocalApiKey();
|
||||
function getApiKey() {
|
||||
const localKey = getLocalApiKey();
|
||||
if (localKey) {
|
||||
dispatch(setApiKey(localKey));
|
||||
setKey(localKey);
|
||||
|
||||
@@ -55,12 +55,11 @@ export default function APIKeyModal({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
async function getRecentDocs() {
|
||||
const response = await getLocalRecentDocs();
|
||||
function getRecentDocs() {
|
||||
const response = getLocalRecentDocs();
|
||||
|
||||
if (response) {
|
||||
const parsedResponse = JSON.parse(response) as Doc;
|
||||
|
||||
dispatch(setSelectedDocs(parsedResponse));
|
||||
setLocalSelectedDocs(parsedResponse);
|
||||
setModalState('INACTIVE');
|
||||
|
||||
@@ -30,38 +30,20 @@ export async function getDocs(): Promise<Doc[] | null> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getLocalApiKey(): Promise<string | null> {
|
||||
try {
|
||||
const key = localStorage.getItem('DocsGPTApiKey');
|
||||
return key;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
export function getLocalApiKey(): string | null {
|
||||
const key = localStorage.getItem('DocsGPTApiKey');
|
||||
return key;
|
||||
}
|
||||
|
||||
export async function getLocalRecentDocs(): Promise<string | null> {
|
||||
try {
|
||||
const doc = localStorage.getItem('DocsGPTRecentDocs');
|
||||
return doc;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
export function getLocalRecentDocs(): string | null {
|
||||
const doc = localStorage.getItem('DocsGPTRecentDocs');
|
||||
return doc;
|
||||
}
|
||||
|
||||
export async function setLocalApiKey(key: string): Promise<void> {
|
||||
try {
|
||||
localStorage.setItem('DocsGPTApiKey', key);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
export function setLocalApiKey(key: string): void {
|
||||
localStorage.setItem('DocsGPTApiKey', key);
|
||||
}
|
||||
|
||||
export async function setLocalRecentDocs(doc: Doc): Promise<void> {
|
||||
try {
|
||||
localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(doc));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
export function setLocalRecentDocs(doc: Doc): void {
|
||||
localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(doc));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user