Skip to content

Commit

Permalink
fix: move dev account in useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Jan 15, 2022
1 parent 5df8a74 commit 5b99e5f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
16 changes: 10 additions & 6 deletions app/assets/javascripts/components/AccountMenu/AdvancedOptions.tsx
Expand Up @@ -3,7 +3,7 @@ import { AppState } from '@/ui_models/app_state';
import { isDev } from '@/utils';
import { observer } from 'mobx-react-lite';
import { FunctionComponent } from 'preact';
import { useState } from 'preact/hooks';
import { useEffect, useState } from 'preact/hooks';
import { Checkbox } from '../Checkbox';
import { Icon } from '../Icon';
import { InputWithIcon } from '../InputWithIcon';
Expand All @@ -20,11 +20,15 @@ export const AdvancedOptions: FunctionComponent<Props> = observer(
appState.accountMenu;
const [showAdvanced, setShowAdvanced] = useState(false);

if (isDev && window._devAccountServer) {
setEnableServerOption(true);
setServer(window._devAccountServer);
application.setCustomHost(window._devAccountServer);
}
useEffect(() => {
if (isDev && window._devAccountServer) {
setEnableServerOption(true);
setServer(window._devAccountServer);
application.setCustomHost(window._devAccountServer);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);


const handleServerOptionChange = (e: Event) => {
if (e.target instanceof HTMLInputElement) {
Expand Down
9 changes: 4 additions & 5 deletions app/assets/javascripts/components/AccountMenu/SignIn.tsx
Expand Up @@ -33,15 +33,14 @@ export const SignInPane: FunctionComponent<Props> = observer(
const emailInputRef = useRef<HTMLInputElement>(null);
const passwordInputRef = useRef<HTMLInputElement>(null);

if (isDev && window._devAccountEmail) {
setEmail(window._devAccountEmail);
setPassword(window._devAccountPassword as string);
}

useEffect(() => {
if (emailInputRef?.current) {
emailInputRef.current?.focus();
}
if (isDev && window._devAccountEmail) {
setEmail(window._devAccountEmail);
setPassword(window._devAccountPassword as string);
}
}, []);

const resetInvalid = () => {
Expand Down

0 comments on commit 5b99e5f

Please sign in to comment.