Skip to content

Commit

Permalink
feat(temp-stands): clean-up old attempts smell
Browse files Browse the repository at this point in the history
  • Loading branch information
niyazm524 committed Nov 27, 2020
1 parent 7ee7caf commit 5e196d3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 135 deletions.
1 change: 1 addition & 0 deletions src/.deploy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./temp-stand";
11 changes: 8 additions & 3 deletions src/shared/helpers/temp-stand.ts → src/.deploy/temp-stand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ const tempStandRegex = /^(github-client-47c49|dev-github-client)--pr\d+.+\.web\.

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()) {
if (!isTempStand() || !devStorageUrl) {
if(!devStorageUrl) {
console.debug(`Note that you need to provide ${STAND_URL_ENV} env to make dev stand work`)
}
return;
}
// Сделал бы через DefinePlugin, но ради этого делать eject не хочется
// @ts-ignore
const { default: createGuest } = await import("cross-domain-storage/guest");
const storage = createGuest("https://dev.github-client.gq/dev/temp-stands.html");
const storage = createGuest(devStorageUrl);
const userCredentialRaw = await new Promise<string | undefined>((resolve, reject) =>
storage.get(CREDENTIAL_KEY, (error: any, data: string | undefined) => {
if (error) {
Expand Down
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from "react";
import ReactDOM from "react-dom";
import App from "./app";
import * as serviceWorker from "./serviceWorker";
import { loadLocalStorageFromDevIfNeeded } from ".deploy";
import "normalize.css";
import "antd/dist/antd.css";
import { loadLocalStorageFromDevIfNeeded } from "./shared/helpers/temp-stand";

function init() {
function renderApp() {
ReactDOM.render(
<React.StrictMode>
<App />
Expand All @@ -15,7 +15,7 @@ function init() {
);
}

loadLocalStorageFromDevIfNeeded().then(init);
loadLocalStorageFromDevIfNeeded().then(renderApp);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
Expand Down
3 changes: 1 addition & 2 deletions src/shared/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as str from "./string";
import * as dom from "./dom";
import * as tempStand from "./temp-stand";

export { str, dom, tempStand };
export { str, dom };
109 changes: 0 additions & 109 deletions src/shared/helpers/xd-local-storage/index.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/shared/helpers/xd-local-storage/services/xd-utils.ts

This file was deleted.

3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@
},
"include": [
"src"
],
"exclude": [
"src/shared/helpers/xd-local-storage/index.ts"
]
}

0 comments on commit 5e196d3

Please sign in to comment.