Skip to content

Commit

Permalink
Last Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Sep 25, 2022
1 parent e54132a commit 413b77b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
10 changes: 6 additions & 4 deletions frontend/src/components/BottomBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ class BottomBar extends Component {

showProfileButton = () => {
return (
this.props.avatarLoaded
// FIXME: Cookies not available on local dev
// (this.props.token ? getCookie('robot_token') == this.props.token : true) &&
// getCookie('sessionid')
this.props.avatarLoaded && (
window.NativeRobosats || (
(this.props.token ? getCookie('robot_token') === this.props.token : true) &&
getCookie('sessionid')
)
)
);
};

Expand Down
34 changes: 17 additions & 17 deletions frontend/src/components/UserGenPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class UserGenPage extends Component {
: this.props.setAppState({
nickname: data.nickname,
token,
avatarLoaded: true,
avatarLoaded: false,
activeOrderId: data.active_order_id ? data.active_order_id : null,
lastOrderId: data.last_order_id ? data.last_order_id : null,
referralCode: data.referral_code,
Expand Down Expand Up @@ -290,10 +290,10 @@ class UserGenPage extends Component {
<IconButton
color='primary'
disabled={
// FIXME: Cookies not available on local dev
// https://github.com/react-native-webview/react-native-webview/issues/2643
// !(getCookie('robot_token') == this.state.token) ||
!this.props.avatarLoaded
!this.props.avatarLoaded || (
!window.NativeRobosats &&
!(getCookie('robot_token') === this.state.token)
)
}
onClick={() =>
saveAsJson(this.state.nickname + '.json', this.createJsonFile())
Expand All @@ -311,10 +311,10 @@ class UserGenPage extends Component {
<IconButton
color={this.props.copiedToken ? 'inherit' : 'primary'}
disabled={
// FIXME: Cookies not available on local dev
// https://github.com/react-native-webview/react-native-webview/issues/2643
// !(getCookie('robot_token') == this.state.token) ||
!this.props.avatarLoaded
!this.props.avatarLoaded || (
!window.NativeRobosats &&
!(getCookie('robot_token') === this.state.token)
)
}
onClick={() =>
copyToClipboard(getCookie('robot_token')) &
Expand Down Expand Up @@ -369,10 +369,10 @@ class UserGenPage extends Component {
<ButtonGroup variant='contained' aria-label='outlined primary button group'>
<Button
disabled={
this.state.loadingRobot !== false
// FIXME: Cookies not available on local dev
// https://github.com/react-native-webview/react-native-webview/issues/2643
// !(this.props.token ? getCookie('robot_token') == this.props.token : true)
this.state.loadingRobot !== false || (
!window.NativeRobosats &&
!(this.props.token ? getCookie('robot_token') === this.props.token : true)
)
}
color='primary'
to='/make/'
Expand All @@ -390,10 +390,10 @@ class UserGenPage extends Component {
/>
<Button
disabled={
this.state.loadingRobot !== false
// FIXME: Cookies not available on local dev
// https://github.com/react-native-webview/react-native-webview/issues/2643
// !(this.props.token ? getCookie('robot_token') == this.props.token : true)
this.state.loadingRobot !== false || (
!window.NativeRobosats &&
!(this.props.token ? getCookie('robot_token') === this.props.token : true)
)
}
color='secondary'
to='/book/'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/api/ApiNativeClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApiNativeClient implements ApiClient {
window.NativeRobosats = new NativeRobosats()
}

private assetsCache : {[path:string]: string} = []
private assetsCache : {[path:string]: string} = {}

private readonly getHeaders: () => HeadersInit = () => {
return { 'Content-Type': 'application/json', 'X-CSRFToken': getCookie('csrftoken') || '' };
Expand Down
2 changes: 1 addition & 1 deletion mobile/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const App = () => {
var uri =
(Platform.OS === 'android' ? 'file:///android_asset/' : '') +
'Web.bundle/index.html';
// const uri = 'https://robosats.onion.moe';

const injectMessage = (id: string, data: object) => {
const json = JSON.stringify(data);
Expand Down Expand Up @@ -70,6 +69,7 @@ const App = () => {
mediaPlaybackRequiresUserAction={false}
allowsLinkPreview={false}
renderLoading={() => <Text>Loading RoboSats</Text>}
onError={syntheticEvent => <Text>{syntheticEvent.type}</Text>}
/>
</SafeAreaView>
);
Expand Down

0 comments on commit 413b77b

Please sign in to comment.