Skip to content

Commit

Permalink
fix(daemon): implement missing bridge methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gfanton committed Apr 17, 2019
1 parent 5c3b866 commit b7e5619
Show file tree
Hide file tree
Showing 7 changed files with 600 additions and 255 deletions.
26 changes: 19 additions & 7 deletions client/react-native/common/bridge/service/daemon/daemon.pb.json
Expand Up @@ -15,7 +15,7 @@
},
"GetLocalGrpcInfos": {
"requestType": "Void",
"responseType": "Void"
"responseType": "GRPCInfos"
},
"GetNetworkConfig": {
"requestType": "Void",
Expand All @@ -29,9 +29,9 @@
"requestType": "Config",
"responseType": "Void"
},
"IsBotRunning": {
"GetBotState": {
"requestType": "Void",
"responseType": "Void"
"responseType": "BotState"
},
"ListAccounts": {
"requestType": "Void",
Expand Down Expand Up @@ -69,10 +69,6 @@
"requestType": "Void",
"responseType": "Void"
},
"ThrowException": {
"requestType": "Void",
"responseType": "Void"
},
"UpdateNetworkConfig": {
"requestType": "NetworkConfig",
"responseType": "Void"
Expand All @@ -82,6 +78,14 @@
"Void": {
"fields": {}
},
"BotState": {
"fields": {
"isBotRunning": {
"type": "bool",
"id": 1
}
}
},
"StartRequest": {
"fields": {
"nickname": {
Expand All @@ -90,6 +94,14 @@
}
}
},
"GRPCInfos": {
"fields": {
"json": {
"type": "string",
"id": 1
}
}
},
"NetworkConfig": {
"fields": {
"json": {
Expand Down
Expand Up @@ -112,10 +112,10 @@ class List extends PureComponent {
const { bridge } = this.props

try {
let running = await bridge.isBotRunning({})
const { isBotRunning } = await bridge.getBotState({})

this.setState({
botRunning: running,
botRunning: isBotRunning,
botStateLoaded: true,
})
} catch (err) {
Expand Down Expand Up @@ -227,45 +227,41 @@ class List extends PureComponent {
return (
<Menu>
<Menu.Section>
{(Platform.OS !== 'web' || Platform.Desktop) && (
<Menu.Item
icon='cpu'
title='Bot mode'
customRight={
<Switch
justify='end'
disabled={!this.state.botStateLoaded}
value={this.state.botRunning}
onValueChange={this.toggleBotState}
/>
}
/>
)}
<Menu.Item
icon='cpu'
title='Bot mode'
customRight={
<Switch
justify='end'
disabled={!this.state.botStateLoaded}
value={this.state.botRunning}
onValueChange={this.toggleBotState}
/>
}
/>
<Menu.Item
icon='refresh-ccw'
title='Restart daemon'
onPress={this.restartDaemon}
/>
{(Platform.OS !== 'web' || Platform.Desktop) && (
<Menu.Item
icon='server'
title={
'Local gRPC (' +
(this.state.localGRPCAddress === ''
? 'no private IP'
: this.state.localGRPCAddress) +
')'
}
customRight={
<Switch
justify='end'
disabled={this.state.localGRPCAddress === ''}
value={this.state.localGRPCRunning}
onValueChange={this.toggleLocalGRPCState}
/>
}
/>
)}
<Menu.Item
icon='server'
title={
'Local gRPC (' +
(this.state.localGRPCAddress === ''
? 'no private IP'
: this.state.localGRPCAddress) +
')'
}
customRight={
<Switch
justify='end'
disabled={this.state.localGRPCAddress === ''}
value={this.state.localGRPCRunning}
onValueChange={this.toggleLocalGRPCState}
/>
}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
Expand Down
8 changes: 0 additions & 8 deletions client/react-native/desktop/main.go
Expand Up @@ -108,10 +108,6 @@ func main() {
homepageUrl = *homepage
}

startRequest := &daemon.StartRequest{
Nickname: "daemon-desktop",
}

d, err := NewDaemonDesktop()
if err != nil {
panic(err)
Expand All @@ -121,10 +117,6 @@ func main() {
panic(err)
}

if _, err := d.bridge.Start(context.Background(), startRequest); err != nil {
panic(err)
}

zap.L().Debug("Berty desktop client started")

// Run bootstrap
Expand Down

0 comments on commit b7e5619

Please sign in to comment.