Fix navbar refactor bugs on native app

This commit is contained in:
Reckless_Satoshi
2022-10-31 09:20:20 -07:00
parent 5c42b5da71
commit c9749bde24
4 changed files with 20 additions and 19 deletions

View File

@ -65,13 +65,11 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
const theme = useTheme(); const theme = useTheme();
const history = useHistory(); const history = useHistory();
const Router = window.NativeRobosats != null ? HashRouter : BrowserRouter; const Router = window.NativeRobosats === undefined ? BrowserRouter : HashRouter;
const basename = window.NativeRobosats != null ? window.location.pathname : ''; const basename = window.NativeRobosats === undefined ? '' : window.location.pathname;
const [page, setPage] = useState<Page>( const entryPage: Page | '' =
window.location.pathname.split('/')[1] == '' window.NativeRobosats === undefined ? window.location.pathname.split('/')[1] : '';
? 'offers' const [page, setPage] = useState<Page>(entryPage == '' ? 'offers' : entryPage);
: window.location.pathname.split('/')[1],
);
const [slideDirection, setSlideDirection] = useState<SlideDirection>({ const [slideDirection, setSlideDirection] = useState<SlideDirection>({
in: undefined, in: undefined,
out: undefined, out: undefined,
@ -166,7 +164,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
? data.active_order_id ? data.active_order_id
: data.last_order_id : data.last_order_id
? data.last_order_id ? data.last_order_id
: order, : null,
); );
setRobot({ setRobot({
...robot, ...robot,

View File

@ -42,10 +42,7 @@ class UserGenPage extends Component {
// Displays the existing one // Displays the existing one
if (this.props.robot.nickname != null) { if (this.props.robot.nickname != null) {
this.setState({ inputToken: this.props.robot.token }); this.setState({ inputToken: this.props.robot.token });
} else if ( } else if (this.props.robot.token) {
this.props.robot.token ||
(window.NativeRobosats && systemClient.getCookie('robot_token'))
) {
this.setState({ inputToken: this.props.robot.token }); this.setState({ inputToken: this.props.robot.token });
this.getGeneratedUser(this.props.robot.token); this.getGeneratedUser(this.props.robot.token);
} else { } else {
@ -117,10 +114,13 @@ class UserGenPage extends Component {
pub_key: data.public_key, pub_key: data.public_key,
enc_priv_key: data.encrypted_private_key, enc_priv_key: data.encrypted_private_key,
copiedToken: data.found ? true : this.props.robot.copiedToken, copiedToken: data.found ? true : this.props.robot.copiedToken,
}); }) &
systemClient.setCookie('robot_token', token); systemClient.setCookie('robot_token', token) &
systemClient.setCookie('pub_key', data.public_key.split('\n').join('\\')); systemClient.setCookie('pub_key', data.public_key.split('\n').join('\\')) &
systemClient.setCookie('enc_priv_key', data.encrypted_private_key.split('\n').join('\\')); systemClient.setCookie(
'enc_priv_key',
data.encrypted_private_key.split('\n').join('\\'),
);
}), }),
); );
}; };

View File

@ -20,11 +20,14 @@ export interface Robot {
copiedToken: boolean; copiedToken: boolean;
} }
const pubKeyCookie = systemClient.getCookie('pub_key');
const privKeyCookie = systemClient.getCookie('enc_priv_key');
export const defaultRobot: Robot = { export const defaultRobot: Robot = {
nickname: null, nickname: null,
token: systemClient.getCookie('robot_token') ?? null, token: systemClient.getCookie('robot_token') ?? null,
pub_key: systemClient.getCookie('pub_key').split('\\').join('\n'), pub_key: pubKeyCookie ? pubKeyCookie.split('\\').join('\n') : null,
enc_priv_key: systemClient.getCookie('enc_priv_key').split('\\').join('\n'), enc_priv_key: privKeyCookie ? privKeyCookie.split('\\').join('\n') : null,
bitsEntropy: null, bitsEntropy: null,
shannonEntropy: null, shannonEntropy: null,
stealthInvoices: true, stealthInvoices: true,