Use FBJS constants instead of strings for even names.

pull/1208/head
Rick Carlino 2019-05-23 10:49:12 -05:00
parent 218d77abab
commit 4ceb0c491d
3 changed files with 18 additions and 13 deletions

View File

@ -7,7 +7,7 @@ default: &default
# See: ENV["DATABASE_URL"]
# https://edgeguides.rubyonrails.org/configuring.html#configuring-a-database
username: postgres
password: <%= ENV["POSTGRES_PASSWORD"] || (puts "Warning - POSTGRES_PASSWORD not found.") %>
password: <%= ENV.fetch("POSTGRES_PASSWORD") %>
development:
<<: *default
database: farmbot_development

View File

@ -1,6 +1,5 @@
if Rails.env == "development"
ENV["NO_EMAILS"] = "true"
POINT_COUNT = 8
PLANT_COUNT = 8
DATE_RANGE_LO = 1..3
@ -39,7 +38,7 @@ if Rails.env == "development"
password_confirmation: "password123",
confirmed_at: Time.now,
agreed_to_terms_at: Time.now)
User.all.update_all(confirmed_at: Time.now,
User.update_all(confirmed_at: Time.now,
agreed_to_terms_at: Time.now)
u = User.last
u.update_attributes(device: Devices::Create.run!(user: u))

View File

@ -2,6 +2,7 @@ import { fetchNewDevice, getDevice } from "../device";
import { dispatchNetworkUp, dispatchNetworkDown } from "./index";
import { Log } from "farmbot/dist/resources/api_resources";
import { Farmbot, BotStateTree, TaggedResource } from "farmbot";
import { FbjsEventName } from "farmbot/dist/constants";
import { noop } from "lodash";
import { success, error, info, warning } from "farmbot-toastr";
import { HardwareState } from "../devices/interfaces";
@ -179,16 +180,21 @@ export const attachEventListeners =
if (bot.client) {
startPinging(bot);
readStatus().then(changeLastClientConnected(bot), noop);
bot.on("online", onOnline);
bot.on("online", () => bot.readStatus().then(noop, noop));
bot.on("offline", onOffline);
bot.on("sent", onSent(bot.client));
bot.on("logs", onLogs(dispatch, getState));
bot.on("legacy_status", onLegacyStatus(dispatch, getState));
bot.on("status_v8", onStatus(dispatch, getState));
bot.on("malformed", onMalformed);
bot.client.subscribe(BROADCAST_CHANNEL);
bot.on(BROADCAST_CHANNEL, onPublicBroadcast);
bot.on(FbjsEventName.online, onOnline);
bot.on(FbjsEventName.online, () => bot.readStatus().then(noop, noop));
bot.on(FbjsEventName.offline, onOffline);
bot.on(FbjsEventName.sent, onSent(bot.client));
bot.on(FbjsEventName.logs, onLogs(dispatch, getState));
bot.on(FbjsEventName.legacy_status, onLegacyStatus(dispatch, getState));
bot.on(FbjsEventName.upsert, onStatus(dispatch, getState));
bot.on(FbjsEventName.remove, (x: {}, y: {}) => {
console.log("REMOVAL!");
console.dir(x, y);
debugger;
});
bot.on(FbjsEventName.malformed, onMalformed);
bot.client.subscribe(FbjsEventName.publicBroadcast);
bot.on(FbjsEventName.publicBroadcast, onPublicBroadcast);
bot.client.on("message", autoSync(dispatch, getState));
bot.client.on("reconnect", onReconnect);
}