Skip to content

Commit

Permalink
feat(temp-stands): using another library to achieve effect
Browse files Browse the repository at this point in the history
  • Loading branch information
niyazm524 committed Nov 27, 2020
1 parent 614ea55 commit aeb438a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@types/react-dom": "^16.9.8",
"antd": "^4.8.5",
"classnames": "^2.2.6",
"cross-domain-storage": "^2.0.7",
"dayjs": "^1.9.6",
"firebase": "^8.0.1",
"graphql": "^15.3.0",
Expand All @@ -27,8 +28,7 @@
"react-scripts": "3.4.3",
"tailwindcss": "^1.9.5",
"typescript": "^3.7.5",
"use-query-params": "^1.1.9",
"xdlocalstorage": "^2.0.5"
"use-query-params": "^1.1.9"
},
"scripts": {
"start": "react-scripts start",
Expand Down
10 changes: 10 additions & 0 deletions public/dev/main.306cbe88.js

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

12 changes: 1 addition & 11 deletions public/dev/temp-stands.html
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Only for development</title>
<script src="xdLocalStorage.min.js"></script>
</head>
<body>

</body>
</html>
<!DOCTYPE html><html lang="ru"><head><meta charset="UTF-8"><title>Dev stands helper</title><script src="main.306cbe88.js"></script></head><body> </body></html>
1 change: 0 additions & 1 deletion public/dev/xdLocalStorage.min.js

This file was deleted.

18 changes: 14 additions & 4 deletions src/shared/helpers/temp-stand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@ export const loadLocalStorageFromDevIfNeeded = async () => {
return;
}
// Сделал бы через DefinePlugin, но ради этого делать eject не хочется
const { default: xdLocalStorage } = await import("./xd-local-storage");
const userCredentialRaw = await new Promise<string>((resolve) =>
xdLocalStorage.getItem(CREDENTIAL_KEY, resolve),
// @ts-ignore
const { default: createGuest } = await import("cross-domain-storage/guest");
const storage = createGuest("https://dev.github-client.gq/dev/temp-stands.html");
const userCredentialRaw = await new Promise<string | undefined>((resolve, reject) =>
storage.get(CREDENTIAL_KEY, (error: any, data: string | undefined) => {
if (error) {
reject(error);
return;
}
resolve(data);
}),
);
localStorage.setItem(CREDENTIAL_KEY, userCredentialRaw);
if (userCredentialRaw) {
localStorage.setItem(CREDENTIAL_KEY, userCredentialRaw);
}
};

0 comments on commit aeb438a

Please sign in to comment.