Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed Aug 11, 2024
2 parents 09d3421 + b3c383f commit 46d0484
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/core/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const createStore = (name: string) => {
const storePath = createStorePath(name);
const state = {} as Record<string, any>;
const getState = async <T = any>(cookiesKey: string | null = 'cookies') => {
const data = await fs.readJson<any>(storePath).catch(() => null);
if (data) Object.assign(state, data);
const data = (await fs.readJson<any>(storePath).catch(() => {})) || {};
Object.assign(state, data);
const cookies = await getCookiesFromTxt(storePath);
const hasCookiesInTxt = !!cookies.length;
const hasCookiesInState = cookiesKey && data?.[cookiesKey];
const hasCookiesInState = cookiesKey && data[cookiesKey];
if (hasCookiesInTxt) http.setCookies(cookies);
else if (hasCookiesInState) http.setCookies(data[cookiesKey]);
return data as T;
Expand Down

0 comments on commit 46d0484

Please sign in to comment.