diff --git a/src/backend/status.js b/src/backend/status.js index 0a1cecb43..e6f34b630 100644 --- a/src/backend/status.js +++ b/src/backend/status.js @@ -5,12 +5,16 @@ const constants = require("./constants"); class ServerStatus { constructor() { this.setState(constants.STARTING); + rnBridge.channel.on("request-status", () => { + log("status request"); + rnBridge.channel.post("status", this.state); + }); } startHeartbeat() { if (this.intervalId) return; // Don't have two heartbeats this.intervalId = setInterval(() => { rnBridge.channel.post("status", this.state); - }, 1000); + }, 4000); } pauseHeartbeat() { clearInterval(this.intervalId); diff --git a/src/frontend/api.js b/src/frontend/api.js index d4aadbe31..29d704973 100644 --- a/src/frontend/api.js +++ b/src/frontend/api.js @@ -147,6 +147,8 @@ export function Api({ // Start server, returns a promise that resolves when the server is ready // or rejects if there is an error starting the server startServer: function startServer(): Promise { + // The server might already be started - request current status + nodejs.channel.post("request-status"); // The server requires read & write permissions for external storage const serverStartPromise = PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,