-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from niyazm524/feature/temp_stands
Finally (сколько можно): работающие temp-стенды [2]
- Loading branch information
Showing
8 changed files
with
215 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./temp-stand"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { CREDENTIAL_KEY } from "features/auth"; | ||
|
||
const tempStandRegex = /^(github-client-47c49|dev-github-client)--pr\d+.+\.web\.app$/; | ||
|
||
const isTempStand = () => tempStandRegex.test(window.location.host); | ||
|
||
const STAND_URL_ENV = "REACT_APP_DEV_STORAGE_URL"; | ||
const devStorageUrl = process.env[STAND_URL_ENV]; | ||
|
||
export const loadLocalStorageFromDevIfNeeded = async () => { | ||
if (!isTempStand() || !devStorageUrl) { | ||
if(!devStorageUrl) { | ||
console.debug(`Note that you need to provide ${STAND_URL_ENV} env to make dev stand work`) | ||
} | ||
return; | ||
} | ||
// @ts-ignore | ||
const { default: createGuest } = await import("cross-domain-storage/guest"); | ||
const storage = createGuest(devStorageUrl); | ||
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); | ||
}), | ||
); | ||
if (userCredentialRaw) { | ||
localStorage.setItem(CREDENTIAL_KEY, userCredentialRaw); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters